Changeset 1271
- Timestamp:
- 01/20/08 21:59:50 (7 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php (modified) (7 diffs)
- trunk/src/test/AllTests.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/xml/XMLTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedGeneratorTestCase.php (modified) (11 diffs)
- trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedItemTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/xml/serializer/annotations/stubXMLMatcherAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerStrategyTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/xml/stubDomXMLStreamWriterTestCase.php (modified) (18 diffs)
- trunk/src/test/php/net/stubbles/xml/stubLibXmlXMLStreamWriterTestCase.php (modified) (9 diffs)
- trunk/src/test/php/net/stubbles/xml/stubXMLStreamWriterFactoryTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/xml/unserializer/stubXMLUnserializerTestCase.php (modified) (11 diffs)
- trunk/src/test/php/net/stubbles/xml/xsl/stubXSLCallbackTestCase.php (modified) (9 diffs)
- trunk/src/test/php/net/stubbles/xml/xsl/stubXSLProcessorTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/xml/xsl/util/stubXSLImageDimensionsTestCase.php (modified) (7 diffs)
- trunk/src/test/run.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php
r1265 r1271 7 7 * @subpackage xml 8 8 */ 9 stubClassLoader::load('net::stubbles::xml::stubXMLStreamWriter', 9 stubClassLoader::load('net::stubbles::lang::exceptions::stubMethodNotSupportedException', 10 'net::stubbles::xml::stubXMLStreamWriter', 10 11 'net::stubbles::xml::stubAbstractXMLStreamWriter' 11 12 ); … … 163 164 * 164 165 * @param stubXMLStreamWriter 165 * @throws stub XMLException166 * @throws stubMethodNotSupportedException 166 167 */ 167 168 public function importStreamWriter(stubXMLStreamWriter $writer) 168 169 { 169 throw new stub XMLException('Operation not supported.');170 throw new stubMethodNotSupportedException('Can not import another stream writer.'); 170 171 } 171 172 trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php
r1229 r1271 125 125 { 126 126 $result = $this->xsltProcessor->setParameter($nameSpace, $paramName, $paramValue); 127 if (false == $result) {127 if (false === $result) { 128 128 return false; 129 129 } 130 130 131 if (isset($this->parameters[$nameSpace]) == false) {131 if (isset($this->parameters[$nameSpace]) === false) { 132 132 $this->parameters[$nameSpace] = array(); 133 133 } … … 158 158 public function getParameter($nameSpace, $paramName) 159 159 { 160 if (isset($this->parameters[$nameSpace][$paramName]) == true) {160 if (isset($this->parameters[$nameSpace][$paramName]) === true) { 161 161 return $this->parameters[$nameSpace][$paramName]; 162 162 } … … 174 174 public function removeParameter($nameSpace, $paramName) 175 175 { 176 if ($this->hasParameter($nameSpace, $paramName) == false) {176 if ($this->hasParameter($nameSpace, $paramName) === false) { 177 177 return true; 178 178 } 179 179 180 180 $result = $this->xsltProcessor->removeParameter($nameSpace, $paramName); 181 if (false == $result) {181 if (false === $result) { 182 182 return false; 183 183 } 184 184 185 185 unset($this->parameters[$nameSpace][$paramName]); 186 if (count($this->parameters[$nameSpace]) == 0) {186 if (count($this->parameters[$nameSpace]) === 0) { 187 187 unset($this->parameters[$nameSpace]); 188 188 } … … 200 200 { 201 201 $result = $this->xsltProcessor->setParameter($nameSpace, $params); 202 if (false == $result) {202 if (false === $result) { 203 203 return false; 204 204 } 205 205 206 if (isset($this->parameters[$nameSpace]) == false) {206 if (isset($this->parameters[$nameSpace]) === false) { 207 207 $this->parameters[$nameSpace] = array(); 208 208 } … … 220 220 public function getParameters($nameSpace) 221 221 { 222 if (isset($this->parameters[$nameSpace]) == true) {222 if (isset($this->parameters[$nameSpace]) === true) { 223 223 return $this->parameters[$nameSpace]; 224 224 } … … 316 316 { 317 317 $this->registerCallbacks(); 318 $result = $this->xsltProcessor->transformToX ml($this->document);318 $result = $this->xsltProcessor->transformToXML($this->document); 319 319 if (false === $result) { 320 320 throw new stubXSLProcessorException($this->createMessage()); … … 353 353 354 354 libxml_clear_errors(); 355 if (strlen($message) == 0) {355 if (strlen($message) === 0) { 356 356 return 'Transformation failed: unknown error.'; 357 357 } trunk/src/test/AllTests.php
r1269 r1271 29 29 require_once $dir . '/php/net/stubbles/websites/WebsitesTestSuite.php'; 30 30 require_once $dir . '/php/net/stubbles/websites/variantmanager/VariantManagerTestSuite.php'; 31 require_once $dir . '/php/net/stubbles/xml/XMLTestSuite.php'; 31 32 /** 32 33 * Class to organize all tests. … … 59 60 $suite->addTestSuite('WebsitesTestSuite'); 60 61 $suite->addTestSuite('VariantManagerTestSuite'); 62 $suite->addTestSuite('XMLTestSuite'); 61 63 return $suite; 62 64 } trunk/src/test/php/net/stubbles/xml/XMLTestSuite.php
r1162 r1271 14 14 * @subpackage test 15 15 */ 16 class XMLTestSuite extends TestSuite16 class XMLTestSuite extends PHPUnit_Framework_TestSuite 17 17 { 18 18 /** 19 * constructor 19 * returns the test suite to be run 20 * 21 * @return PHPUnit_Framework_TestSuite 20 22 */ 21 public function __construct()23 public static function suite() 22 24 { 23 $ this->TestSuite('All XML tests');24 $dir = dirname(__FILE__);25 $ this->addTestFile($dir . '/stubXMLStreamWriterFactoryTestCase.php');26 $ this->addTestFile($dir . '/stubDomXMLStreamWriterTestCase.php');27 $ this->addTestFile($dir . '/stubLibXmlXMLStreamWriterTestCase.php');25 $suite = new self(); 26 $dir = dirname(__FILE__); 27 $suite->addTestFile($dir . '/stubXMLStreamWriterFactoryTestCase.php'); 28 $suite->addTestFile($dir . '/stubDomXMLStreamWriterTestCase.php'); 29 $suite->addTestFile($dir . '/stubLibXmlXMLStreamWriterTestCase.php'); 28 30 29 31 // serializer 30 $ this->addTestFile($dir . '/serializer/stubXMLSerializerTestCase.php');31 $ this->addTestFile($dir . '/serializer/stubXMLSerializerStrategyTestCase.php');32 $ this->addTestFile($dir . '/serializer/annotations/stubXMLMatcherAnnotationTestCase.php');32 $suite->addTestFile($dir . '/serializer/stubXMLSerializerTestCase.php'); 33 $suite->addTestFile($dir . '/serializer/stubXMLSerializerStrategyTestCase.php'); 34 $suite->addTestFile($dir . '/serializer/annotations/stubXMLMatcherAnnotationTestCase.php'); 33 35 34 36 // unserializer 35 $ this->addTestFile($dir . '/unserializer/stubXMLUnserializerTestCase.php');37 $suite->addTestFile($dir . '/unserializer/stubXMLUnserializerTestCase.php'); 36 38 37 39 // rss 38 $ this->addTestFile($dir . '/rss/stubRSSFeedGeneratorTestCase.php');39 $ this->addTestFile($dir . '/rss/stubRSSFeedItemTestCase.php');40 $suite->addTestFile($dir . '/rss/stubRSSFeedGeneratorTestCase.php'); 41 $suite->addTestFile($dir . '/rss/stubRSSFeedItemTestCase.php'); 40 42 41 43 // xsl 42 $this->addTestFile($dir . '/xsl/stubXSLCallbackTestCase.php'); 43 $this->addTestFile($dir . '/xsl/stubXSLProcessorTestCase.php'); 44 $this->addTestFile($dir . '/xsl/util/stubXSLImageDimensionsTestCase.php'); 44 $suite->addTestFile($dir . '/xsl/stubXSLCallbackTestCase.php'); 45 $suite->addTestFile($dir . '/xsl/stubXSLProcessorTestCase.php'); 46 $suite->addTestFile($dir . '/xsl/util/stubXSLImageDimensionsTestCase.php'); 47 return $suite; 45 48 } 46 49 } trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedGeneratorTestCase.php
r1229 r1271 8 8 */ 9 9 stubClassLoader::load('net::stubbles::xml::rss::stubRSSFeedGenerator'); 10 Mock::generate('stubXMLStreamWriter');11 10 /** 12 11 * Test for net::stubbles::xml::rss::stubRSSFeedGenerator. … … 15 14 * @subpackage xml_rss_test 16 15 */ 17 class stubRSSFeedGeneratorTestCase extends UnitTestCase16 class stubRSSFeedGeneratorTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 34 33 /** 35 34 * test that the values are handles as expexted 35 * 36 * @test 36 37 */ 37 public function testNoItemsNoStylesheets()38 public function noItemsNoStylesheets() 38 39 { 39 $this->assertEqual ($this->rssFeedGenerator->countItems(), 0);40 $this->assertEquals(0, $this->rssFeedGenerator->countItems()); 40 41 41 $mockXmlStreamWriter = new MockstubXMLStreamWriter();42 $mockXmlStreamWriter->expect Never('writeProcessingInstruction');43 $mockXmlStreamWriter->expect CallCount('writeStartElement', 2);44 $mockXmlStreamWriter->expect CallCount('writeEndElement', 2);45 $mockXmlStreamWriter->expect CallCount('writeElement', 4);42 $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 43 $mockXmlStreamWriter->expects($this->never())->method('writeProcessingInstruction'); 44 $mockXmlStreamWriter->expects($this->exactly(2))->method('writeStartElement'); 45 $mockXmlStreamWriter->expects($this->exactly(2))->method('writeEndElement'); 46 $mockXmlStreamWriter->expects($this->exactly(4))->method('writeElement'); 46 47 $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 47 48 } … … 49 50 /** 50 51 * test that the values are handles as expexted 52 * 53 * @test 51 54 */ 52 public function testNoItemsWithStylesheets()55 public function noItemsWithStylesheets() 53 56 { 54 57 $this->rssFeedGenerator->appendStylesheet('foo.xsl'); 55 $mockXmlStreamWriter = new MockstubXMLStreamWriter();56 $mockXmlStreamWriter->expect CallCount('writeProcessingInstruction', 1);57 $mockXmlStreamWriter->expect CallCount('writeStartElement', 2);58 $mockXmlStreamWriter->expect CallCount('writeEndElement', 2);59 $mockXmlStreamWriter->expect CallCount('writeElement', 4);58 $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 59 $mockXmlStreamWriter->expects($this->once())->method('writeProcessingInstruction'); 60 $mockXmlStreamWriter->expects($this->exactly(2))->method('writeStartElement'); 61 $mockXmlStreamWriter->expects($this->exactly(2))->method('writeEndElement'); 62 $mockXmlStreamWriter->expects($this->exactly(4))->method('writeElement'); 60 63 $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 61 64 } … … 63 66 /** 64 67 * test that the values are handles as expexted 68 * 69 * @test 65 70 */ 66 public function testWithItemsNoStylesheets()71 public function withItemsNoStylesheets() 67 72 { 68 $this->assertEqual ($this->rssFeedGenerator->countItems(), 0);73 $this->assertEquals(0, $this->rssFeedGenerator->countItems()); 69 74 $this->rssFeedGenerator->addItem('foo', 'bar', 'baz'); 70 $this->assertEqual ($this->rssFeedGenerator->countItems(), 1);71 $mockXmlStreamWriter = new MockstubXMLStreamWriter();72 $mockXmlStreamWriter->expect Never('writeProcessingInstruction');73 $mockXmlStreamWriter->expect MinimumCallCount('writeStartElement', 2);74 $mockXmlStreamWriter->expect MinimumCallCount('writeEndElement', 2);75 $mockXmlStreamWriter->expect MinimumCallCount('writeElement', 4);75 $this->assertEquals(1, $this->rssFeedGenerator->countItems()); 76 $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 77 $mockXmlStreamWriter->expects($this->never())->method('writeProcessingInstruction'); 78 $mockXmlStreamWriter->expects($this->exactly(3))->method('writeStartElement'); 79 $mockXmlStreamWriter->expects($this->exactly(3))->method('writeEndElement'); 80 $mockXmlStreamWriter->expects($this->exactly(8))->method('writeElement'); 76 81 $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 77 82 } … … 79 84 /** 80 85 * test that optional channel elements are handled as expected 86 * 87 * @test 81 88 */ 82 public function testWithAllChannelElements()89 public function withAllChannelElements() 83 90 { 84 91 $this->rssFeedGenerator->setLanguage('en_EN'); … … 90 97 $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo'); 91 98 92 $mockXmlStreamWriter = new MockstubXMLStreamWriter();93 $mockXmlStreamWriter->expect Never('writeProcessingInstruction');94 $mockXmlStreamWriter->expect CallCount('writeStartElement', 3);95 $mockXmlStreamWriter->expect CallCount('writeEndElement', 3);96 $mockXmlStreamWriter->expect CallCount('writeElement', 16);99 $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 100 $mockXmlStreamWriter->expects($this->never())->method('writeProcessingInstruction'); 101 $mockXmlStreamWriter->expects($this->exactly(3))->method('writeStartElement'); 102 $mockXmlStreamWriter->expects($this->exactly(3))->method('writeEndElement'); 103 $mockXmlStreamWriter->expects($this->exactly(16))->method('writeElement'); 97 104 $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 98 105 } … … 100 107 /** 101 108 * assure that invalid dates throw a stubXMLException 109 * 110 * @test 111 * @expectedException stubXMLException 102 112 */ 103 public function testInvalidLastBuildDate()113 public function invalidLastBuildDate() 104 114 { 105 $this->expectException('stubXMLException');106 115 $this->rssFeedGenerator->setLastBuildDate('foo'); 107 116 } … … 109 118 /** 110 119 * assure that an invalid width throws a stubXMLException 120 * 121 * @test 122 * @expectedException stubXMLException 111 123 */ 112 public function testImageWidthTooSmall()124 public function imageWidthTooSmall() 113 125 { 114 $this->expectException('stubXMLException');115 126 $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', -1); 116 127 } … … 118 129 /** 119 130 * assure that an invalid width throws a stubXMLException 131 * 132 * @test 133 * @expectedException stubXMLException 120 134 */ 121 public function testImageWidthTooGreat()135 public function imageWidthTooGreat() 122 136 { 123 $this->expectException('stubXMLException');124 137 $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', 145); 125 138 } … … 127 140 /** 128 141 * assure that an invalid height throws a stubXMLException 142 * 143 * @test 144 * @expectedException stubXMLException 129 145 */ 130 public function testImageHeightTooSmall()146 public function imageHeightTooSmall() 131 147 { 132 $this->expectException('stubXMLException'); 133 $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', -1); 148 $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', -1); 134 149 } 135 150 136 151 /** 137 152 * assure that an invalid height throws a stubXMLException 153 * 154 * @test 155 * @expectedException stubXMLException 138 156 */ 139 public function testImageHeightTooGreat()157 public function imageHeightTooGreat() 140 158 { 141 $this->expectException('stubXMLException');142 159 $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', 401); 143 160 } trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedItemTestCase.php
r1229 r1271 8 8 */ 9 9 stubClassLoader::load('net::stubbles::xml::rss::stubRSSFeedItem'); 10 Mock::generate('stubXMLStreamWriter');11 10 /** 12 11 * Test for net::stubbles::xml::rss::stubRSSFeedItem. … … 15 14 * @subpackage xml_rss_test 16 15 */ 17 class stubRSSFeedItemTestCase extends UnitTestCase16 class stubRSSFeedItemTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 51 50 /** 52 51 * test that the values are handles as expexted 52 * 53 * @test 53 54 */ 54 public function testValues()55 public function values() 55 56 { 56 $this->assertEqual($this->rssFeedItem1->getTitle(), 'test1'); 57 $this->assertEqual($this->rssFeedItem1->getLink(), 'http://stubbles.net/'); 58 $this->assertEqual($this->rssFeedItem1->getDescription(), 'description'); 59 $this->assertEqual($this->rssFeedItem1->getAuthor(), 'nospam@example.com (mikey)'); 60 $this->assertEqual($this->rssFeedItem1->getCategories(), array(array('category' => 'cat1', 61 'domain' => '' 62 ), 63 array('category' => 'cat2', 64 'domain' => 'domain' 65 ) 66 ) 57 $this->assertEquals('test1', $this->rssFeedItem1->getTitle()); 58 $this->assertEquals('http://stubbles.net/', $this->rssFeedItem1->getLink()); 59 $this->assertEquals('description', $this->rssFeedItem1->getDescription()); 60 $this->assertEquals('nospam@example.com (mikey)', $this->rssFeedItem1->getAuthor()); 61 $this->assertEquals(array(array('category' => 'cat1', 62 'domain' => '' 63 ), 64 array('category' => 'cat2', 65 'domain' => 'domain' 66 ) 67 ), 68 $this->rssFeedItem1->getCategories() 67 69 ); 68 $this->assertEqual($this->rssFeedItem1->getComments(), 'http://stubbles.net/comments/'); 69 $this->assertEqual($this->rssFeedItem1->getEnclosures(), array(array('url' => 'http://stubbles.net/enclosure.mp3', 70 'length' => 50, 71 'type' => 'audio/mpeg' 72 ) 73 ) 70 $this->assertEquals('http://stubbles.net/comments/', $this->rssFeedItem1->getComments()); 71 $this->assertEquals(array(array('url' => 'http://stubbles.net/enclosure.mp3', 72 'length' => 50, 73 'type' => 'audio/mpeg' 74 ) 75 ), 76 $this->rssFeedItem1->getEnclosures() 74 77 ); 75 $this->assertEqual ($this->rssFeedItem1->getGuid(), 'dummy');78 $this->assertEquals('dummy', $this->rssFeedItem1->getGuid()); 76 79 $this->assertTrue($this->rssFeedItem1->isGuidPermaLink()); 77 $this->assertEqual($this->rssFeedItem1->getPubDate(), 'Thu 01 Jan 1970 01:00:50 +0100'); 78 $this->assertEqual($this->rssFeedItem1->getSources(), array(array('name' => 'stubbles', 79 'url' => 'http://stubbles.net/source/' 80 ) 81 ) 80 $this->assertEquals('Thu 01 Jan 1970 01:00:50 +0100', $this->rssFeedItem1->getPubDate()); 81 $this->assertEquals(array(array('name' => 'stubbles', 82 'url' => 'http://stubbles.net/source/' 83 ) 84 ), 85 $this->rssFeedItem1->getSources() 82 86 ); 83 87 84 88 $this->rssFeedItem1->byAuthor('test@example.net (mikey)'); 85 $this->assertEqual ($this->rssFeedItem1->getAuthor(), 'test@example.net (mikey)');89 $this->assertEquals('test@example.net (mikey)', $this->rssFeedItem1->getAuthor()); 86 90 87 91 $this->rssFeedItem1->withGuid('dummy2', false); 88 $this->assertEqual ($this->rssFeedItem1->getGuid(), 'dummy2');92 $this->assertEquals('dummy2', $this->rssFeedItem1->getGuid()); 89 93 $this->assertFalse($this->rssFeedItem1->isGuidPermaLink()); 90 94 } … … 92 96 /** 93 97 * test that the values are handles as expexted 98 * 99 * @test 94 100 */ 95 public function testEmptyValues()101 public function emptyValues() 96 102 { 97 $this->assertEqual ($this->rssFeedItem2->getTitle(), 'test2');98 $this->assertEqual ($this->rssFeedItem2->getLink(), 'http://stubbles.net/');99 $this->assertEqual ($this->rssFeedItem2->getDescription(), 'description2');103 $this->assertEquals('test2', $this->rssFeedItem2->getTitle()); 104 $this->assertEquals('http://stubbles.net/', $this->rssFeedItem2->getLink()); 105 $this->assertEquals('description2', $this->rssFeedItem2->getDescription()); 100 106 $this->assertNull($this->rssFeedItem2->getAuthor()); 101 $this->assertEqual ($this->rssFeedItem2->getCategories(), array());107 $this->assertEquals(array(), $this->rssFeedItem2->getCategories()); 102 108 $this->assertNull($this->rssFeedItem2->getComments()); 103 $this->assertEqual ($this->rssFeedItem2->getEnclosures(), array());109 $this->assertEquals(array(), $this->rssFeedItem2->getEnclosures()); 104 110 $this->assertNull($this->rssFeedItem2->getGuid()); 105 111 $this->assertNull($this->rssFeedItem2->getPubDate()); 106 $this->assertEqual ($this->rssFeedItem2->getSources(), array());107 $this->assertEqual ($this->rssFeedItem2->getContent(), '');112 $this->assertEquals(array(), $this->rssFeedItem2->getSources()); 113 $this->assertEquals('', $this->rssFeedItem2->getContent()); 108 114 } 109 115 110 116 /** 111 117 * testz that serializing the rss item works as expected 118 * 119 * @test 112 120 */ 113 public function testSerialize()121 public function serialize() 114 122 { 115 $mockXmlStreamWriter = new MockstubXMLStreamWriter();116 $mockXmlStreamWriter->expect Once('writeStartElement', array('item'));117 $mockXmlStreamWriter->expect CallCount('writeElement', 12);123 $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 124 $mockXmlStreamWriter->expects($this->once())->method('writeStartElement'); 125 $mockXmlStreamWriter->expects($this->exactly(12))->method('writeElement'); 118 126 $this->rssFeedItem1->serialize($mockXmlStreamWriter); 119 127 } … … 121 129 /** 122 130 * testz that serializing the rss item works as expected 131 * 132 * @test 123 133 */ 124 public function testEmptySerialize()134 public function emptySerialize() 125 135 { 126 $mockXmlStreamWriter = new MockstubXMLStreamWriter();127 $mockXmlStreamWriter->expect Once('writeStartElement', array('item'));128 $mockXmlStreamWriter->expect CallCount('writeElement', 4);136 $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 137 $mockXmlStreamWriter->expects($this->once())->method('writeStartElement'); 138 $mockXmlStreamWriter->expects($this->exactly(4))->method('writeElement'); 129 139 $this->rssFeedItem2->serialize($mockXmlStreamWriter); 130 140 } trunk/src/test/php/net/stubbles/xml/serializer/annotations/stubXMLMatcherAnnotationTestCase.php
r1229 r1271 27 27 * @subpackage xml_test 28 28 */ 29 class stubXMLMatcherAnnotationTestCase extends UnitTestCase29 class stubXMLMatcherAnnotationTestCase extends PHPUnit_Framework_TestCase 30 30 { 31 31 32 32 /** 33 33 * Test a matching pattern for a property 34 * 35 * @test 34 36 */ 35 public function testMatchingPatternForProperty() { 37 public function matchingPatternForProperty() 38 { 36 39 $matcher = new stubXMLMatcherAnnotation(); 37 40 $matcher->setPattern('/.+/'); 38 41 39 42 $tagName = $matcher->getTagnameForProperty(new stubReflectionProperty('stubXMLMatcherAnnotationTestCase_Foo', 'bar'), 'foo'); 40 $this->assertEqual ('bar', $tagName);43 $this->assertEquals('bar', $tagName); 41 44 } 42 45 43 46 /** 44 47 * Test a matching pattern for a method 48 * 49 * @test 45 50 */ 46 public function testMatchingPatternForMethod() { 51 public function matchingPatternForMethod() 52 { 47 53 $matcher = new stubXMLMatcherAnnotation(); 48 54 $matcher->setPattern('/^get(.+)/'); 49 55 50 56 $tagName = $matcher->getTagnameForMethod(new stubReflectionMethod('stubXMLMatcherAnnotationTestCase_Foo', 'getBar'), 'foo'); 51 $this->assertEqual ('bar', $tagName);57 $this->assertEquals('bar', $tagName); 52 58 } 53 59 54 60 /** 55 61 * Test a non-matching pattern for a property 62 * 63 * @test 56 64 */ 57 public function testNonMatchingPatternForProperty() { 65 public function nonMatchingPatternForProperty() 66 { 58 67 $matcher = new stubXMLMatcherAnnotation(); 59 68 $matcher->setPattern('/^[0-9]+$/'); … … 65 74 /** 66 75 * Test a non-matching pattern for a method 76 * 77 * @test 67 78 */ 68 public function testNonMatchingPatternForMethod() { 79 public function nonMatchingPatternForMethod() 80 { 69 81 $matcher = new stubXMLMatcherAnnotation(); 70 82 $matcher->setPattern('/^getFoo/'); … … 76 88 /** 77 89 * Test an invalid pattern with a property 90 * 91 * @test 92 * @expectedException stubXMLException 78 93 */ 79 public function testInvalidPatternForProperty() { 94 public function invalidPatternForProperty() 95 { 80 96 $matcher = new stubXMLMatcherAnnotation(); 81 97 $matcher->setPattern('/foo'); 82 98 83 $this->expectException('stubXMLException'); 84 $matcher->getTagnameForProperty(new stubReflectionProperty('stubXMLMatcherAnnotationTestCase_Foo', 'bar'), 'foo'); 99 @$matcher->getTagnameForProperty(new stubReflectionProperty('stubXMLMatcherAnnotationTestCase_Foo', 'bar'), 'foo'); 85 100 } 86 101 87 102 /** 88 103 * Test an invalid pattern with a method 104 * 105 * @test 106 * @expectedException stubXMLException 89 107 */ 90 public function testInvalidPatternForMethod() { 108 public function invalidPatternForMethod() 109 { 91 110 $matcher = new stubXMLMatcherAnnotation(); 92 111 $matcher->setPattern('/foo'); 93 112 94 $this->expectException('stubXMLException'); 95 $matcher->getTagnameFormethod(new stubReflectionMethod('stubXMLMatcherAnnotationTestCase_Foo', 'getBar'), 'foo'); 113 @$matcher->getTagnameFormethod(new stubReflectionMethod('stubXMLMatcherAnnotationTestCase_Foo', 'getBar'), 'foo'); 96 114 } 97 115 } trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerStrategyTestCase.php
r1229 r1271 92 92 * @subpackage xml_test 93 93 */ 94 class stubXMLSerializerStrategyTestCase extends UnitTestCase94 class stubXMLSerializerStrategyTestCase extends PHPUnit_Framework_TestCase 95 95 { 96 96 … … 107 107 * Creates the serializer instance 108 108 */ 109 public function setUp() { 109 public function setUp() 110 { 110 111 $this->serializer = new stubXMLSerializer(); 111 112 } … … 115 116 * 116 117 * @todo Implement tests for mixing annotations with strategies 117 */ 118 public function testDefaultObjectStrategies() { 118 * 119 * @test 120 */ 121 public function defaultObjectStrategies() 122 { 119 123 $obj = new testXMLSerializerStrategyDefault(); 120 124 … … 122 126 $writer = new stubDomXMLStreamWriter(); 123 127 $this->serializer->serialize($obj, $writer); 124 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><foo>foo</foo><getBar>bar</getBar></testXMLSerializerStrategyDefault>', $writer->asXML());128 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><foo>foo</foo><getBar>bar</getBar></testXMLSerializerStrategyDefault>', $writer->asXML()); 125 129 126 130 // STRATEGY_ALL 127 131 $writer = new stubDomXMLStreamWriter(); 128 132 $this->serializer->serialize($obj, $writer, array(stubXMLSerializer::OPT_STRATEGY => stubXMLSerializer::STRATEGY_ALL)); 129 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><foo>foo</foo><getBar>bar</getBar></testXMLSerializerStrategyDefault>', $writer->asXML());133 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><foo>foo</foo><getBar>bar</getBar></testXMLSerializerStrategyDefault>', $writer->asXML()); 130 134 131 135 // STRATEGY_NONE 132 136 $writer = new stubDomXMLStreamWriter(); 133 137 $this->serializer->serialize($obj, $writer, array(stubXMLSerializer::OPT_STRATEGY => stubXMLSerializer::STRATEGY_NONE)); 134 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault/>', $writer->asXML());138 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault/>', $writer->asXML()); 135 139 136 140 // STRATEGY_PROPS 137 141 $writer = new stubDomXMLStreamWriter(); 138 142 $this->serializer->serialize($obj, $writer, array(stubXMLSerializer::OPT_STRATEGY => stubXMLSerializer::STRATEGY_PROPS)); 139 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><foo>foo</foo></testXMLSerializerStrategyDefault>', $writer->asXML());143 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><foo>foo</foo></testXMLSerializerStrategyDefault>', $writer->asXML()); 140 144 141 145 // STRATEGY_METHODS 142 146 $writer = new stubDomXMLStreamWriter(); 143 147 $this->serializer->serialize($obj, $writer, array(stubXMLSerializer::OPT_STRATEGY => stubXMLSerializer::STRATEGY_METHODS)); 144 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><getBar>bar</getBar></testXMLSerializerStrategyDefault>', $writer->asXML());148 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<testXMLSerializerStrategyDefault><getBar>bar</getBar></testXMLSerializerStrategyDefault>', $writer->asXML()); 145 149 } 146 150 147 151 /** 148 152 * Test serializing an object with the XMLStrategy=ALL annotation 149 */ 150 public function testStrategyAll() { 153 * 154 * @test 155 */ 156 public function strategyAll() 157 { 151 158 $obj = new testXMLSerializerStrategyAll(); 152 159 153 160 $writer = new stubDomXMLStreamWriter(); 154 161 $this->serializer->serialize($obj, $writer); 155 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj><prop>propValue</prop><method>return</method></obj>', $writer->asXML());162 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj><prop>propValue</prop><method>return</method></obj>', $writer->asXML()); 156 163 } 157 164 158 165 /** 159 166 * Test serializing an object with the XMLStrategy=PROPS annotation 160 */ 161 public function testStrategyProps() { 167 * 168 * @test 169 */ 170 public function strategyProps() 171 { 162 172 $obj = new testXMLSerializerStrategyProps(); 163 173 164 174 $writer = new stubDomXMLStreamWriter(); 165 175 $this->serializer->serialize($obj, $writer); 166 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj><prop>propValue</prop></obj>', $writer->asXML());176 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj><prop>propValue</prop></obj>', $writer->asXML()); 167 177 } 168 178 169 179 /** 170 180 * Test serializing an object with the XMLStrategy=METHODS annotation 171 */ 172 public function testStrategyMethods() { 181 * 182 * @test 183 */ 184 public function strategyMethods() 185 { 173 186 $obj = new testXMLSerializerStrategyMethods(); 174 187 175 188 $writer = new stubDomXMLStreamWriter(); 176 189 $this->serializer->serialize($obj, $writer); 177 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj><method>return</method></obj>', $writer->asXML());190 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj><method>return</method></obj>', $writer->asXML()); 178 191 } 179 192 180 193 /** 181 194 * Test serializing an object with the XMLStrategy=NONE annotation 182 */ 183 public function testStrategyNone() { 195 * 196 * @test 197 */ 198 public function strategyNone() 199 { 184 200 $obj = new testXMLSerializerStrategyNone(); 185 201 186 202 $writer = new stubDomXMLStreamWriter(); 187 203 $this->serializer->serialize($obj, $writer); 188 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj/>', $writer->asXML());204 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<obj/>', $writer->asXML()); 189 205 } 190 206 } trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerTestCase.php
r1229 r1271 252 252 * @subpackage xml_test 253 253 */ 254 class stubXMLSerializerTestCase extends UnitTestCase254 class stubXMLSerializerTestCase extends PHPUnit_Framework_TestCase 255 255 { 256 257 256 /** 258 257 * The XMLSerializer to use … … 262 261 protected $serializer; 263 262 264 public function setUp() { 263 /** 264 * set up test environment 265 */ 266 public function setUp() 267 { 265 268 $this->serializer = new stubXMLSerializer(); 266 269 } … … 268 271 /** 269 272 * Test serializing a null value 270 */ 271 public function testNull() { 273 * 274 * @test 275 */ 276 public function null() 277 { 272 278 $writer = new stubDomXMLStreamWriter(); 273 279 $this->serializer->serialize(null, $writer, array(stubXMLSerializer::OPT_ROOT_TAG => 'root')); 274 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root><null/></root>', $writer->asXML());280 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root><null/></root>', $writer->asXML()); 275 281 } 276 282 277 283 /** 278 284 * Test serializing a string 279 */ 280 public function testString() { 285 * 286 * @test 287 */ 288 public function string() 289 { 281 290 $writer = new stubDomXMLStreamWriter(); 282 291 $this->serializer->serialize('This is a string.', $writer, array(stubXMLSerializer::OPT_ROOT_TAG => 'root')); 283 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root>This is a string.</root>', $writer->asXML());292 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root>This is a string.</root>', $writer->asXML()); 284 293 } 285 294 286 295 /** 287 296 * Test serializing an integer 288 */ 289 public function testInteger() { 297 * 298 * @test 299 */ 300 public function integer() 301 { 290 302 $writer = new stubDomXMLStreamWriter(); 291 303 $this->serializer->serialize(45, $writer, array(stubXMLSerializer::OPT_ROOT_TAG => 'root')); 292 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root>45</root>', $writer->asXML());304 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root>45</root>', $writer->asXML()); 293 305 } 294 306 295 307 /** 296 308 * Test serializing a float 297 */ 298 public function testFloat() { 309 * 310 * @test 311 */ 312 public function float() 313 { 299 314 $writer = new stubDomXMLStreamWriter(); 300 315 $this->serializer->serialize(2.352, $writer, array(stubXMLSerializer::OPT_ROOT_TAG => 'root')); 301 $this->assertEqual ('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root>2.352</root>', $writer->asXML());316 $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<root>2.352</root>', $writer-&g
