Changeset 1271

Show
Ignore:
Timestamp:
01/20/08 21:59:50 (7 months ago)
Author:
mikey
Message:

continued refactoring #118: converted tests for net::stubbles::xml

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php

    r1265 r1271  
    77 * @subpackage  xml 
    88 */ 
    9 stubClassLoader::load('net::stubbles::xml::stubXMLStreamWriter', 
     9stubClassLoader::load('net::stubbles::lang::exceptions::stubMethodNotSupportedException', 
     10                      'net::stubbles::xml::stubXMLStreamWriter', 
    1011                      'net::stubbles::xml::stubAbstractXMLStreamWriter' 
    1112); 
     
    163164     * 
    164165     * @param   stubXMLStreamWriter 
    165      * @throws  stubXMLException 
     166     * @throws  stubMethodNotSupportedException 
    166167     */ 
    167168    public function importStreamWriter(stubXMLStreamWriter $writer) 
    168169    { 
    169         throw new stubXMLException('Operation not supported.'); 
     170        throw new stubMethodNotSupportedException('Can not import another stream writer.'); 
    170171    } 
    171172 
  • trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php

    r1229 r1271  
    125125    { 
    126126        $result = $this->xsltProcessor->setParameter($nameSpace, $paramName, $paramValue); 
    127         if (false == $result) { 
     127        if (false === $result) { 
    128128            return false; 
    129129        } 
    130130         
    131         if (isset($this->parameters[$nameSpace]) == false) { 
     131        if (isset($this->parameters[$nameSpace]) === false) { 
    132132            $this->parameters[$nameSpace] = array(); 
    133133        } 
     
    158158    public function getParameter($nameSpace, $paramName) 
    159159    { 
    160         if (isset($this->parameters[$nameSpace][$paramName]) == true) { 
     160        if (isset($this->parameters[$nameSpace][$paramName]) === true) { 
    161161            return $this->parameters[$nameSpace][$paramName]; 
    162162        } 
     
    174174    public function removeParameter($nameSpace, $paramName) 
    175175    { 
    176         if ($this->hasParameter($nameSpace, $paramName) == false) { 
     176        if ($this->hasParameter($nameSpace, $paramName) === false) { 
    177177            return true; 
    178178        } 
    179179         
    180180        $result = $this->xsltProcessor->removeParameter($nameSpace, $paramName); 
    181         if (false == $result) { 
     181        if (false === $result) { 
    182182            return false; 
    183183        } 
    184184         
    185185        unset($this->parameters[$nameSpace][$paramName]); 
    186         if (count($this->parameters[$nameSpace]) == 0) { 
     186        if (count($this->parameters[$nameSpace]) === 0) { 
    187187            unset($this->parameters[$nameSpace]); 
    188188        } 
     
    200200    { 
    201201        $result = $this->xsltProcessor->setParameter($nameSpace, $params); 
    202         if (false == $result) { 
     202        if (false === $result) { 
    203203            return false; 
    204204        } 
    205205         
    206         if (isset($this->parameters[$nameSpace]) == false) { 
     206        if (isset($this->parameters[$nameSpace]) === false) { 
    207207            $this->parameters[$nameSpace] = array(); 
    208208        } 
     
    220220    public function getParameters($nameSpace) 
    221221    { 
    222         if (isset($this->parameters[$nameSpace]) == true) { 
     222        if (isset($this->parameters[$nameSpace]) === true) { 
    223223            return $this->parameters[$nameSpace]; 
    224224        } 
     
    316316    { 
    317317        $this->registerCallbacks(); 
    318         $result = $this->xsltProcessor->transformToXml($this->document); 
     318        $result = $this->xsltProcessor->transformToXML($this->document); 
    319319        if (false === $result) { 
    320320            throw new stubXSLProcessorException($this->createMessage()); 
     
    353353 
    354354        libxml_clear_errors(); 
    355         if (strlen($message) == 0) { 
     355        if (strlen($message) === 0) { 
    356356            return 'Transformation failed: unknown error.'; 
    357357        } 
  • trunk/src/test/AllTests.php

    r1269 r1271  
    2929require_once $dir . '/php/net/stubbles/websites/WebsitesTestSuite.php'; 
    3030require_once $dir . '/php/net/stubbles/websites/variantmanager/VariantManagerTestSuite.php'; 
     31require_once $dir . '/php/net/stubbles/xml/XMLTestSuite.php'; 
    3132/** 
    3233 * Class to organize all tests. 
     
    5960        $suite->addTestSuite('WebsitesTestSuite'); 
    6061        $suite->addTestSuite('VariantManagerTestSuite'); 
     62        $suite->addTestSuite('XMLTestSuite'); 
    6163        return $suite; 
    6264    } 
  • trunk/src/test/php/net/stubbles/xml/XMLTestSuite.php

    r1162 r1271  
    1414 * @subpackage  test 
    1515 */ 
    16 class XMLTestSuite extends TestSuite 
     16class XMLTestSuite extends PHPUnit_Framework_TestSuite 
    1717{ 
    1818    /** 
    19      * constructor 
     19     * returns the test suite to be run 
     20     * 
     21     * @return  PHPUnit_Framework_TestSuite 
    2022     */ 
    21     public function __construct() 
     23    public static function suite() 
    2224    { 
    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'); 
    2830 
    2931        // 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'); 
    3335         
    3436        // unserializer 
    35         $this->addTestFile($dir . '/unserializer/stubXMLUnserializerTestCase.php'); 
     37        $suite->addTestFile($dir . '/unserializer/stubXMLUnserializerTestCase.php'); 
    3638 
    3739        // 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'); 
    4042 
    4143        // 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; 
    4548    } 
    4649} 
  • trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedGeneratorTestCase.php

    r1229 r1271  
    88 */ 
    99stubClassLoader::load('net::stubbles::xml::rss::stubRSSFeedGenerator'); 
    10 Mock::generate('stubXMLStreamWriter'); 
    1110/** 
    1211 * Test for net::stubbles::xml::rss::stubRSSFeedGenerator. 
     
    1514 * @subpackage  xml_rss_test 
    1615 */ 
    17 class stubRSSFeedGeneratorTestCase extends UnitTestCase 
     16class stubRSSFeedGeneratorTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    3433    /** 
    3534     * test that the values are handles as expexted 
     35     * 
     36     * @test 
    3637     */ 
    37     public function testNoItemsNoStylesheets() 
     38    public function noItemsNoStylesheets() 
    3839    { 
    39         $this->assertEqual($this->rssFeedGenerator->countItems(), 0); 
     40        $this->assertEquals(0, $this->rssFeedGenerator->countItems()); 
    4041         
    41         $mockXmlStreamWriter = new MockstubXMLStreamWriter(); 
    42         $mockXmlStreamWriter->expectNever('writeProcessingInstruction'); 
    43         $mockXmlStreamWriter->expectCallCount('writeStartElement', 2); 
    44         $mockXmlStreamWriter->expectCallCount('writeEndElement', 2); 
    45         $mockXmlStreamWriter->expectCallCount('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'); 
    4647        $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 
    4748    } 
     
    4950    /** 
    5051     * test that the values are handles as expexted 
     52     * 
     53     * @test 
    5154     */ 
    52     public function testNoItemsWithStylesheets() 
     55    public function noItemsWithStylesheets() 
    5356    { 
    5457        $this->rssFeedGenerator->appendStylesheet('foo.xsl'); 
    55         $mockXmlStreamWriter = new MockstubXMLStreamWriter(); 
    56         $mockXmlStreamWriter->expectCallCount('writeProcessingInstruction', 1); 
    57         $mockXmlStreamWriter->expectCallCount('writeStartElement', 2); 
    58         $mockXmlStreamWriter->expectCallCount('writeEndElement', 2); 
    59         $mockXmlStreamWriter->expectCallCount('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'); 
    6063        $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 
    6164    } 
     
    6366    /** 
    6467     * test that the values are handles as expexted 
     68     * 
     69     * @test 
    6570     */ 
    66     public function testWithItemsNoStylesheets() 
     71    public function withItemsNoStylesheets() 
    6772    { 
    68         $this->assertEqual($this->rssFeedGenerator->countItems(), 0); 
     73        $this->assertEquals(0, $this->rssFeedGenerator->countItems()); 
    6974        $this->rssFeedGenerator->addItem('foo', 'bar', 'baz'); 
    70         $this->assertEqual($this->rssFeedGenerator->countItems(), 1); 
    71         $mockXmlStreamWriter = new MockstubXMLStreamWriter(); 
    72         $mockXmlStreamWriter->expectNever('writeProcessingInstruction'); 
    73         $mockXmlStreamWriter->expectMinimumCallCount('writeStartElement', 2); 
    74         $mockXmlStreamWriter->expectMinimumCallCount('writeEndElement', 2); 
    75         $mockXmlStreamWriter->expectMinimumCallCount('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'); 
    7681        $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 
    7782    } 
     
    7984    /** 
    8085     * test that optional channel elements are handled as expected 
     86     * 
     87     * @test 
    8188     */ 
    82     public function testWithAllChannelElements() 
     89    public function withAllChannelElements() 
    8390    { 
    8491        $this->rssFeedGenerator->setLanguage('en_EN'); 
     
    9097        $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo'); 
    9198         
    92         $mockXmlStreamWriter = new MockstubXMLStreamWriter(); 
    93         $mockXmlStreamWriter->expectNever('writeProcessingInstruction'); 
    94         $mockXmlStreamWriter->expectCallCount('writeStartElement', 3); 
    95         $mockXmlStreamWriter->expectCallCount('writeEndElement', 3); 
    96         $mockXmlStreamWriter->expectCallCount('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'); 
    97104        $this->rssFeedGenerator->serialize($mockXmlStreamWriter); 
    98105    } 
     
    100107    /** 
    101108     * assure that invalid dates throw a stubXMLException 
     109     * 
     110     * @test 
     111     * @expectedException  stubXMLException 
    102112     */ 
    103     public function testInvalidLastBuildDate() 
     113    public function invalidLastBuildDate() 
    104114    { 
    105         $this->expectException('stubXMLException'); 
    106115        $this->rssFeedGenerator->setLastBuildDate('foo'); 
    107116    } 
     
    109118    /** 
    110119     * assure that an invalid width throws a stubXMLException 
     120     * 
     121     * @test 
     122     * @expectedException  stubXMLException 
    111123     */ 
    112     public function testImageWidthTooSmall() 
     124    public function imageWidthTooSmall() 
    113125    { 
    114         $this->expectException('stubXMLException'); 
    115126        $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', -1); 
    116127    } 
     
    118129    /** 
    119130     * assure that an invalid width throws a stubXMLException 
     131     * 
     132     * @test 
     133     * @expectedException  stubXMLException 
    120134     */ 
    121     public function testImageWidthTooGreat() 
     135    public function imageWidthTooGreat() 
    122136    { 
    123         $this->expectException('stubXMLException'); 
    124137        $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', 145); 
    125138    } 
     
    127140    /** 
    128141     * assure that an invalid height throws a stubXMLException 
     142     * 
     143     * @test 
     144     * @expectedException  stubXMLException 
    129145     */ 
    130     public function testImageHeightTooSmall() 
     146    public function imageHeightTooSmall() 
    131147    { 
    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); 
    134149    } 
    135150     
    136151    /** 
    137152     * assure that an invalid height throws a stubXMLException 
     153     * 
     154     * @test 
     155     * @expectedException  stubXMLException 
    138156     */ 
    139     public function testImageHeightTooGreat() 
     157    public function imageHeightTooGreat() 
    140158    { 
    141         $this->expectException('stubXMLException'); 
    142159        $this->rssFeedGenerator->setImage('http://example.org/example.gif', 'foo', 401); 
    143160    } 
  • trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedItemTestCase.php

    r1229 r1271  
    88 */ 
    99stubClassLoader::load('net::stubbles::xml::rss::stubRSSFeedItem'); 
    10 Mock::generate('stubXMLStreamWriter'); 
    1110/** 
    1211 * Test for net::stubbles::xml::rss::stubRSSFeedItem. 
     
    1514 * @subpackage  xml_rss_test 
    1615 */ 
    17 class stubRSSFeedItemTestCase extends UnitTestCase 
     16class stubRSSFeedItemTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    5150    /** 
    5251     * test that the values are handles as expexted 
     52     * 
     53     * @test 
    5354     */ 
    54     public function testValues() 
     55    public function values() 
    5556    { 
    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() 
    6769        ); 
    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() 
    7477        ); 
    75         $this->assertEqual($this->rssFeedItem1->getGuid(), 'dummy'); 
     78        $this->assertEquals('dummy', $this->rssFeedItem1->getGuid()); 
    7679        $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() 
    8286        ); 
    8387         
    8488        $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()); 
    8690         
    8791        $this->rssFeedItem1->withGuid('dummy2', false); 
    88         $this->assertEqual($this->rssFeedItem1->getGuid(), 'dummy2'); 
     92        $this->assertEquals('dummy2', $this->rssFeedItem1->getGuid()); 
    8993        $this->assertFalse($this->rssFeedItem1->isGuidPermaLink()); 
    9094    } 
     
    9296    /** 
    9397     * test that the values are handles as expexted 
     98     * 
     99     * @test 
    94100     */ 
    95     public function testEmptyValues() 
     101    public function emptyValues() 
    96102    { 
    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()); 
    100106        $this->assertNull($this->rssFeedItem2->getAuthor()); 
    101         $this->assertEqual($this->rssFeedItem2->getCategories(), array()); 
     107        $this->assertEquals(array(), $this->rssFeedItem2->getCategories()); 
    102108        $this->assertNull($this->rssFeedItem2->getComments()); 
    103         $this->assertEqual($this->rssFeedItem2->getEnclosures(), array()); 
     109        $this->assertEquals(array(), $this->rssFeedItem2->getEnclosures()); 
    104110        $this->assertNull($this->rssFeedItem2->getGuid()); 
    105111        $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()); 
    108114    } 
    109115     
    110116    /** 
    111117     * testz that serializing the rss item works as expected 
     118     * 
     119     * @test 
    112120     */ 
    113     public function testSerialize() 
     121    public function serialize() 
    114122    { 
    115         $mockXmlStreamWriter = new MockstubXMLStreamWriter(); 
    116         $mockXmlStreamWriter->expectOnce('writeStartElement', array('item')); 
    117         $mockXmlStreamWriter->expectCallCount('writeElement', 12); 
     123        $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 
     124        $mockXmlStreamWriter->expects($this->once())->method('writeStartElement'); 
     125        $mockXmlStreamWriter->expects($this->exactly(12))->method('writeElement'); 
    118126        $this->rssFeedItem1->serialize($mockXmlStreamWriter); 
    119127    } 
     
    121129    /** 
    122130     * testz that serializing the rss item works as expected 
     131     * 
     132     * @test 
    123133     */ 
    124     public function testEmptySerialize() 
     134    public function emptySerialize() 
    125135    { 
    126         $mockXmlStreamWriter = new MockstubXMLStreamWriter(); 
    127         $mockXmlStreamWriter->expectOnce('writeStartElement', array('item')); 
    128         $mockXmlStreamWriter->expectCallCount('writeElement', 4); 
     136        $mockXmlStreamWriter = $this->getMock('stubXMLStreamWriter'); 
     137        $mockXmlStreamWriter->expects($this->once())->method('writeStartElement'); 
     138        $mockXmlStreamWriter->expects($this->exactly(4))->method('writeElement'); 
    129139        $this->rssFeedItem2->serialize($mockXmlStreamWriter); 
    130140    } 
  • trunk/src/test/php/net/stubbles/xml/serializer/annotations/stubXMLMatcherAnnotationTestCase.php

    r1229 r1271  
    2727 * @subpackage  xml_test 
    2828 */ 
    29 class stubXMLMatcherAnnotationTestCase extends UnitTestCase 
     29class stubXMLMatcherAnnotationTestCase extends PHPUnit_Framework_TestCase 
    3030{ 
    3131 
    3232    /** 
    3333     * Test a matching pattern for a property 
     34     * 
     35     * @test 
    3436     */ 
    35     public function testMatchingPatternForProperty() { 
     37    public function matchingPatternForProperty() 
     38    { 
    3639        $matcher = new stubXMLMatcherAnnotation(); 
    3740        $matcher->setPattern('/.+/'); 
    3841 
    3942        $tagName = $matcher->getTagnameForProperty(new stubReflectionProperty('stubXMLMatcherAnnotationTestCase_Foo', 'bar'), 'foo'); 
    40         $this->assertEqual('bar', $tagName); 
     43        $this->assertEquals('bar', $tagName); 
    4144    } 
    4245 
    4346    /** 
    4447     * Test a matching pattern for a method 
     48     * 
     49     * @test 
    4550     */ 
    46     public function testMatchingPatternForMethod() { 
     51    public function matchingPatternForMethod() 
     52    { 
    4753        $matcher = new stubXMLMatcherAnnotation(); 
    4854        $matcher->setPattern('/^get(.+)/'); 
    4955 
    5056        $tagName = $matcher->getTagnameForMethod(new stubReflectionMethod('stubXMLMatcherAnnotationTestCase_Foo', 'getBar'), 'foo'); 
    51         $this->assertEqual('bar', $tagName); 
     57        $this->assertEquals('bar', $tagName); 
    5258    } 
    5359 
    5460    /** 
    5561     * Test a non-matching pattern for a property 
     62     * 
     63     * @test 
    5664     */ 
    57     public function testNonMatchingPatternForProperty() { 
     65    public function nonMatchingPatternForProperty() 
     66    { 
    5867        $matcher = new stubXMLMatcherAnnotation(); 
    5968        $matcher->setPattern('/^[0-9]+$/'); 
     
    6574    /** 
    6675     * Test a non-matching pattern for a method 
     76     * 
     77     * @test 
    6778     */ 
    68     public function testNonMatchingPatternForMethod() { 
     79    public function nonMatchingPatternForMethod() 
     80    { 
    6981        $matcher = new stubXMLMatcherAnnotation(); 
    7082        $matcher->setPattern('/^getFoo/'); 
     
    7688    /** 
    7789     * Test an invalid pattern with a property 
     90     * 
     91     * @test 
     92     * @expectedException  stubXMLException 
    7893     */ 
    79     public function testInvalidPatternForProperty() { 
     94    public function invalidPatternForProperty() 
     95    { 
    8096        $matcher = new stubXMLMatcherAnnotation(); 
    8197        $matcher->setPattern('/foo'); 
    8298 
    83         $this->expectException('stubXMLException'); 
    84         $matcher->getTagnameForProperty(new stubReflectionProperty('stubXMLMatcherAnnotationTestCase_Foo', 'bar'), 'foo'); 
     99        @$matcher->getTagnameForProperty(new stubReflectionProperty('stubXMLMatcherAnnotationTestCase_Foo', 'bar'), 'foo'); 
    85100    } 
    86101 
    87102    /** 
    88103     * Test an invalid pattern with a method 
     104     * 
     105     * @test 
     106     * @expectedException  stubXMLException 
    89107     */ 
    90     public function testInvalidPatternForMethod() { 
     108    public function invalidPatternForMethod() 
     109    { 
    91110        $matcher = new stubXMLMatcherAnnotation(); 
    92111        $matcher->setPattern('/foo'); 
    93112 
    94         $this->expectException('stubXMLException'); 
    95         $matcher->getTagnameFormethod(new stubReflectionMethod('stubXMLMatcherAnnotationTestCase_Foo', 'getBar'), 'foo'); 
     113        @$matcher->getTagnameFormethod(new stubReflectionMethod('stubXMLMatcherAnnotationTestCase_Foo', 'getBar'), 'foo'); 
    96114    } 
    97115} 
  • trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerStrategyTestCase.php

    r1229 r1271  
    9292 * @subpackage  xml_test 
    9393 */ 
    94 class stubXMLSerializerStrategyTestCase extends UnitTestCase 
     94class stubXMLSerializerStrategyTestCase extends PHPUnit_Framework_TestCase 
    9595{ 
    9696 
     
    107107     * Creates the serializer instance 
    108108     */ 
    109     public function setUp() { 
     109    public function setUp() 
     110    { 
    110111        $this->serializer = new stubXMLSerializer(); 
    111112    } 
     
    115116     * 
    116117     * @todo Implement tests for mixing annotations with strategies 
    117      */ 
    118     public function testDefaultObjectStrategies() { 
     118     * 
     119     * @test 
     120     */ 
     121    public function defaultObjectStrategies() 
     122    { 
    119123        $obj = new testXMLSerializerStrategyDefault(); 
    120124 
     
    122126        $writer = new stubDomXMLStreamWriter(); 
    123127        $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()); 
    125129 
    126130        // STRATEGY_ALL 
    127131        $writer = new stubDomXMLStreamWriter(); 
    128132        $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()); 
    130134 
    131135        // STRATEGY_NONE 
    132136        $writer = new stubDomXMLStreamWriter(); 
    133137        $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()); 
    135139 
    136140        // STRATEGY_PROPS 
    137141        $writer = new stubDomXMLStreamWriter(); 
    138142        $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()); 
    140144 
    141145        // STRATEGY_METHODS 
    142146        $writer = new stubDomXMLStreamWriter(); 
    143147        $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()); 
    145149    } 
    146150 
    147151    /** 
    148152     * Test serializing an object with the XMLStrategy=ALL annotation 
    149      */ 
    150     public function testStrategyAll() { 
     153     * 
     154     * @test 
     155     */ 
     156    public function strategyAll() 
     157    { 
    151158        $obj = new testXMLSerializerStrategyAll(); 
    152159 
    153160        $writer = new stubDomXMLStreamWriter(); 
    154161        $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()); 
    156163    } 
    157164 
    158165    /** 
    159166     * Test serializing an object with the XMLStrategy=PROPS annotation 
    160      */ 
    161     public function testStrategyProps() { 
     167     * 
     168     * @test 
     169     */ 
     170    public function strategyProps() 
     171    { 
    162172        $obj = new testXMLSerializerStrategyProps(); 
    163173 
    164174        $writer = new stubDomXMLStreamWriter(); 
    165175        $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()); 
    167177    } 
    168178 
    169179    /** 
    170180     * Test serializing an object with the XMLStrategy=METHODS annotation 
    171      */ 
    172     public function testStrategyMethods() { 
     181     * 
     182     * @test 
     183     */ 
     184    public function strategyMethods() 
     185    { 
    173186        $obj = new testXMLSerializerStrategyMethods(); 
    174187 
    175188        $writer = new stubDomXMLStreamWriter(); 
    176189        $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()); 
    178191    } 
    179192 
    180193    /** 
    181194     * Test serializing an object with the XMLStrategy=NONE annotation 
    182      */ 
    183     public function testStrategyNone() { 
     195     * 
     196     * @test 
     197     */ 
     198    public function strategyNone() 
     199    { 
    184200        $obj = new testXMLSerializerStrategyNone(); 
    185201 
    186202        $writer = new stubDomXMLStreamWriter(); 
    187203        $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()); 
    189205    } 
    190206} 
  • trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerTestCase.php

    r1229 r1271  
    252252 * @subpackage  xml_test 
    253253 */ 
    254 class stubXMLSerializerTestCase extends UnitTestCase 
     254class stubXMLSerializerTestCase extends PHPUnit_Framework_TestCase 
    255255{ 
    256  
    257256    /** 
    258257     * The XMLSerializer to use 
     
    262261    protected $serializer; 
    263262 
    264     public function setUp() { 
     263    /** 
     264     * set up test environment 
     265     */ 
     266    public function setUp() 
     267    { 
    265268        $this->serializer = new stubXMLSerializer(); 
    266269    } 
     
    268271    /** 
    269272     * Test serializing a null value 
    270      */ 
    271     public function testNull() { 
     273     * 
     274     * @test 
     275     */ 
     276    public function null() 
     277    { 
    272278        $writer = new stubDomXMLStreamWriter(); 
    273279        $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()); 
    275281    } 
    276282 
    277283    /** 
    278284     * Test serializing a string 
    279      */ 
    280     public function testString() { 
     285     * 
     286     * @test 
     287     */ 
     288    public function string() 
     289    { 
    281290        $writer = new stubDomXMLStreamWriter(); 
    282291        $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()); 
    284293    } 
    285294 
    286295    /** 
    287296     * Test serializing an integer 
    288      */ 
    289     public function testInteger() { 
     297     * 
     298     * @test 
     299     */ 
     300    public function integer() 
     301    { 
    290302        $writer = new stubDomXMLStreamWriter(); 
    291303        $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()); 
    293305    } 
    294306 
    295307    /** 
    296308     * Test serializing a float 
    297      */ 
    298     public function testFloat() { 
     309     * 
     310     * @test 
     311     */ 
     312    public function float() 
     313    { 
    299314        $writer = new stubDomXMLStreamWriter(); 
    300315        $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