Changeset 1236

Show
Ignore:
Timestamp:
01/14/08 00:02:35 (8 months ago)
Author:
mikey
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/test/AllTests.php

    r1235 r1236  
    2222PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/org'); 
    2323 
     24require_once $dir . '/php/net/stubbles/stubTestSuite.php'; 
    2425require_once $dir . '/php/net/stubbles/auth/AuthTestSuite.php'; 
    2526require_once $dir . '/php/net/stubbles/events/EventTestSuite.php'; 
     
    4849    public static function suite() 
    4950    { 
    50         $suite   = new self(); 
    51         $dirname = dirname(__FILE__); 
    52          
    53         $suite->addTestFile($dirname . '/php/net/stubbles/stubClassLoaderTestCase.php'); 
     51        $suite = new self(); 
     52        $suite->addTestSuite('stubTestSuite'); 
    5453        $suite->addTestSuite('AuthTestSuite'); 
    5554        $suite->addTestSuite('EventTestSuite'); 
  • trunk/src/test/php/net/stubbles/lang/errorhandler/stubAbstractExceptionHandlerTestCase.php

    r1209 r1236  
    1111                      'net::stubbles::util::log::stubMemoryLogAppender' 
    1212); 
    13 Mock::generate('stubSession'); 
    14 Mock::generatePartial('stubAbstractExceptionHandler', 'PartialMock1stubAbstractExceptionHandler', array('fillResponse')); 
    15 Mock::generatePartial('stubAbstractExceptionHandler', 'PartialMock2stubAbstractExceptionHandler', array('fillResponse', 'log')); 
    1613/** 
    1714 * Chained exception for test purposes. 
     
    3835 * @subpackage  lang_errorhandler_test 
    3936 */ 
    40 class stubAbstractExceptionHandlerTestCase extends UnitTestCase 
     37class stubAbstractExceptionHandlerTestCase extends PHPUnit_Framework_TestCase 
    4138{ 
    4239    /** 
     
    5249    public function setUp() 
    5350    { 
    54         $this->abstractExceptionHandler = new PartialMock1stubAbstractExceptionHandler(); 
     51        $this->abstractExceptionHandler = $this->getMock('stubAbstractExceptionHandler', array('fillResponse')); 
    5552        stubRegistry::setConfig('net.stubbles.util.log.class', 'net::stubbles::util::log::stubBaseLogData'); 
    5653        $binder = new stubBinder(); 
     
    7471    /** 
    7572     * assure that disabling logging works correct 
     73     * 
     74     * @test 
    7675     */ 
    77     public function LoggingDisabled() 
     76    public function loggingDisabled() 
    7877    { 
    79         $abstractExceptionHandler = new PartialMock2stubAbstractExceptionHandler(); 
    80         $abstractExceptionHandler->expectNever('log'); 
     78        $abstractExceptionHandler = $this->getMock('stubAbstractExceptionHandler', array('fillResponse', 'log')); 
     79        $abstractExceptionHandler->expects($this->never())->method('log'); 
    8180        $abstractExceptionHandler->setLogging(false); 
    8281        $abstractExceptionHandler->handleException(new Exception()); 
     
    8584    /** 
    8685     * assure that the exception is logged 
     86     * 
     87     * @test 
    8788     */ 
    88     public function testHandleException() 
     89    public function handleException() 
    8990    { 
    9091        $logger      = stubLogger::getInstance(__CLASS__); 
     
    9495        $line = __LINE__ - 1; 
    9596        $logData = $logAppender->getLogData(); 
    96         $this->assertEqual(count($logData), 1); 
    97         $this->assertEqual(count($logData['exceptions']), 1); 
    98         $this->assertEqual($logData['exceptions'][0]->getTarget(), 'exceptions'); 
    99         $this->assertEqual($logData['exceptions'][0]->getLevel(), stubLogger::LEVEL_ERROR); 
     97        $this->assertEquals(1, count($logData)); 
     98        $this->assertEquals(1, count($logData['exceptions'])); 
     99        $this->assertEquals('exceptions', $logData['exceptions'][0]->getTarget()); 
     100        $this->assertEquals(stubLogger::LEVEL_ERROR, $logData['exceptions'][0]->getLevel()); 
    100101        $logDataContents = explode(stubLogData::SEPERATOR, $logData['exceptions'][0]->get()); 
    101         $this->assertEqual($logDataContents[1], 'Exception'); 
    102         $this->assertEqual($logDataContents[2], 'exception message'); 
    103         $this->assertEqual($logDataContents[3], __FILE__); 
    104         $this->assertEqual($logDataContents[4], $line); 
    105         $this->assertEqual($logDataContents[5], ''); 
    106         $this->assertEqual($logDataContents[6], ''); 
    107         $this->assertEqual($logDataContents[7], ''); 
    108         $this->assertEqual($logDataContents[8], ''); 
     102        $this->assertEquals('Exception', $logDataContents[1]); 
     103        $this->assertEquals('exception message', $logDataContents[2]); 
     104        $this->assertEquals(__FILE__, $logDataContents[3]); 
     105        $this->assertEquals($line, $logDataContents[4]); 
     106        $this->assertEquals('', $logDataContents[5]); 
     107        $this->assertEquals('', $logDataContents[6]); 
     108        $this->assertEquals('', $logDataContents[7]); 
     109        $this->assertEquals('', $logDataContents[8]); 
    109110        stubLogger::destroyInstance(__CLASS__); 
    110111    } 
     
    112113    /** 
    113114     * assure that the exception is logged 
     115     * 
     116     * @test 
    114117     */ 
    115     public function testHandleChainedException() 
     118    public function handleChainedException() 
    116119    { 
    117120        $logger      = stubLogger::getInstance(__CLASS__); 
     
    124127        $this->abstractExceptionHandler->handleException($exception); 
    125128        $logData = $logAppender->getLogData(); 
    126         $this->assertEqual(count($logData), 1); 
    127         $this->assertEqual(count($logData['foo']), 1); 
    128         $this->assertEqual($logData['foo'][0]->getTarget(), 'foo'); 
    129         $this->assertEqual($logData['foo'][0]->getLevel(), stubLogger::LEVEL_DEBUG); 
     129        $this->assertEquals(1, count($logData)); 
     130        $this->assertEquals(1, count($logData['foo'])); 
     131        $this->assertEquals('foo', $logData['foo'][0]->getTarget()); 
     132        $this->assertEquals(stubLogger::LEVEL_DEBUG, $logData['foo'][0]->getLevel()); 
    130133        $logDataContents = explode(stubLogData::SEPERATOR, $logData['foo'][0]->get()); 
    131         $this->assertEqual($logDataContents[1], 'net::stubbles::lang::errorhandler::test::TestAbstractExceptionHandlerException'); 
    132         $this->assertEqual($logDataContents[2], 'chained exception'); 
    133         $this->assertEqual($logDataContents[3], __FILE__); 
    134         $this->assertEqual($logDataContents[4], $line); 
    135         $this->assertEqual($logDataContents[5], 'Exception'); 
    136         $this->assertEqual($logDataContents[6], 'exception message'); 
    137         $this->assertEqual($logDataContents[7], __FILE__); 
    138         $this->assertEqual($logDataContents[8], $line); 
     134        $this->assertEquals('net::stubbles::lang::errorhandler::test::TestAbstractExceptionHandlerException', $logDataContents[1]); 
     135        $this->assertEquals('chained exception', $logDataContents[2]); 
     136        $this->assertEquals(__FILE__, $logDataContents[3]); 
     137        $this->assertEquals($line, $logDataContents[4]); 
     138        $this->assertEquals('Exception', $logDataContents[5]); 
     139        $this->assertEquals('exception message', $logDataContents[6]); 
     140        $this->assertEquals(__FILE__, $logDataContents[7]); 
     141        $this->assertEquals($line, $logDataContents[8]); 
    139142        stubLogger::destroyInstance(__CLASS__); 
    140143    } 
  • trunk/src/test/php/net/stubbles/lang/errorhandler/stubCompositeErrorHandlerTestCase.php

    r1209 r1236  
    88 */ 
    99stubClassLoader::load('net::stubbles::lang::errorhandler::stubCompositeErrorHandler'); 
    10 Mock::generate('stubErrorHandler'); 
    1110/** 
    1211 * Tests for net::stubbles::lang::errorhandler::stubCompositeErrorHandler 
     
    1514 * @subpackage  lang_errorhandler_test 
    1615 */ 
    17 class stubCompositeErrorHandlerTestCase extends UnitTestCase 
     16class stubCompositeErrorHandlerTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    2625     * a mocked error handler 
    2726     * 
    28      * @var  SimpleMock 
     27     * @var  PHPUnit_Framework_MockObject_MockObject 
    2928     */ 
    3029    protected $mockErrorHandler1; 
     
    3231     * a mocked error handler 
    3332     * 
    34      * @var  SimpleMock 
     33     * @var  PHPUnit_Framework_MockObject_MockObject 
    3534     */ 
    3635    protected $mockErrorHandler2; 
     
    3837     * a mocked error handler 
    3938     * 
    40      * @var  SimpleMock 
     39     * @var  PHPUnit_Framework_MockObject_MockObject 
    4140     */ 
    4241    protected $mockErrorHandler3; 
     
    4847    { 
    4948        $this->compositeErrorHandler = new stubCompositeErrorHandler(); 
    50         $this->mockErrorHandler1     = new MockstubErrorHandler(); 
     49        $this->mockErrorHandler1     = $this->getMock('stubErrorHandler'); 
    5150        $this->compositeErrorHandler->addErrorHandler($this->mockErrorHandler1); 
    52         $this->mockErrorHandler2     = new MockstubErrorHandler(); 
     51        $this->mockErrorHandler2     = $this->getMock('stubErrorHandler'); 
    5352        $this->compositeErrorHandler->addErrorHandler($this->mockErrorHandler2); 
    54         $this->mockErrorHandler3     = new MockstubErrorHandler(); 
     53        $this->mockErrorHandler3     = $this->getMock('stubErrorHandler'); 
    5554        $this->compositeErrorHandler->addErrorHandler($this->mockErrorHandler3); 
    5655    } 
     
    5857    /** 
    5958     * assert that all registered handlers are returned 
    60      */ 
    61     public function testGetHandlers() 
    62     { 
    63         $this->assertEqual($this->compositeErrorHandler->getErrorHandlers(), array($this->mockErrorHandler1, 
    64                                                                                    $this->mockErrorHandler2, 
    65                                                                                    $this->mockErrorHandler3 
    66                                                                              ) 
     59     * 
     60     * @test 
     61     */ 
     62    public function getHandlers() 
     63    { 
     64        $this->assertEquals(array($this->mockErrorHandler1, 
     65                                  $this->mockErrorHandler2, 
     66                                  $this->mockErrorHandler3 
     67                            ), 
     68                            $this->compositeErrorHandler->getErrorHandlers() 
    6769        ); 
    6870    } 
     
    7072    /** 
    7173     * assure that isResponsible() works correct 
    72      */ 
    73     public function testIsResponsible() 
    74     { 
    75         $this->mockErrorHandler1->setReturnValue('isResponsible', false); 
    76         $this->mockErrorHandler1->expectCallcount('isResponsible', 2); 
    77         $this->mockErrorHandler2->setReturnValueAt(0, 'isResponsible', true); 
    78         $this->mockErrorHandler2->setReturnValueAt(1, 'isResponsible', false); 
    79         $this->mockErrorHandler2->expectCallcount('isResponsible', 2); 
    80         $this->mockErrorHandler3->setReturnValue('isResponsible', false); 
    81         $this->mockErrorHandler3->expectOnce('isResponsible'); 
     74     * 
     75     * @test 
     76     */ 
     77    public function isResponsible() 
     78    { 
     79        $this->mockErrorHandler1->expects($this->exactly(2)) 
     80                                ->method('isResponsible') 
     81                                ->will($this->returnValue(false)); 
     82        $this->mockErrorHandler2->expects($this->exactly(2)) 
     83                                ->method('isResponsible') 
     84                                ->will($this->onConsecutiveCalls(true, false)); 
     85        $this->mockErrorHandler3->expects($this->once()) 
     86                                ->method('isResponsible') 
     87                                ->will($this->returnValue(false)); 
    8288        $this->assertTrue($this->compositeErrorHandler->isResponsible(1, 'foo')); 
    8389        $this->assertFalse($this->compositeErrorHandler->isResponsible(1, 'foo')); 
     
    8692    /** 
    8793     * assure that isSupressable() works correct 
    88      */ 
    89     public function testIsSupressable() 
    90     { 
    91         $this->mockErrorHandler1->setReturnValue('isSupressable', true); 
    92         $this->mockErrorHandler1->expectCallcount('isSupressable', 2); 
    93         $this->mockErrorHandler2->setReturnValueAt(0, 'isSupressable', false); 
    94         $this->mockErrorHandler2->setReturnValueAt(1, 'isSupressable', true); 
    95         $this->mockErrorHandler2->expectCallcount('isSupressable', 2); 
    96         $this->mockErrorHandler3->setReturnValue('isSupressable', true); 
    97         $this->mockErrorHandler3->expectOnce('isSupressable'); 
     94     * 
     95     * @test 
     96     */ 
     97    public function isSupressable() 
     98    { 
     99        $this->mockErrorHandler1->expects($this->exactly(2)) 
     100                                ->method('isSupressable') 
     101                                ->will($this->returnValue(true)); 
     102        $this->mockErrorHandler2->expects($this->exactly(2)) 
     103                                ->method('isSupressable') 
     104                                ->will($this->onConsecutiveCalls(false, true)); 
     105        $this->mockErrorHandler3->expects($this->once()) 
     106                                ->method('isSupressable') 
     107                                ->will($this->returnValue(true)); 
    98108        $this->assertFalse($this->compositeErrorHandler->isSupressable(1, 'foo')); 
    99109        $this->assertTrue($this->compositeErrorHandler->isSupressable(1, 'foo')); 
     
    102112    /** 
    103113     * assure that handle() works correct 
    104      */ 
    105     public function testHandleWithoutResonsibility() 
    106     { 
    107         $this->mockErrorHandler1->setReturnValue('isResponsible', false); 
    108         $this->mockErrorHandler1->expectNever('isSupressable'); 
    109         $this->mockErrorHandler1->expectNever('handle'); 
    110         $this->mockErrorHandler2->setReturnValue('isResponsible', false); 
    111         $this->mockErrorHandler2->expectNever('isSupressable'); 
    112         $this->mockErrorHandler2->expectNever('handle'); 
    113         $this->mockErrorHandler3->setReturnValue('isResponsible', false); 
    114         $this->mockErrorHandler3->expectNever('isSupressable'); 
    115         $this->mockErrorHandler3->expectNever('handle'); 
    116         $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 
    117     } 
    118  
    119     /** 
    120      * assure that handle() works correct 
    121      */ 
    122     public function testHandleWithSupressAndErrorReportingDisabled() 
     114     * 
     115     * @test 
     116     */ 
     117    public function handleWithoutResonsibility() 
     118    { 
     119        $this->mockErrorHandler1->expects($this->once()) 
     120                                ->method('isResponsible') 
     121                                ->will($this->returnValue(false)); 
     122        $this->mockErrorHandler1->expects($this->never()) 
     123                                ->method('isSupressable'); 
     124        $this->mockErrorHandler1->expects($this->never()) 
     125                                ->method('handle'); 
     126        $this->mockErrorHandler2->expects($this->once()) 
     127                                ->method('isResponsible') 
     128                                ->will($this->returnValue(false)); 
     129        $this->mockErrorHandler2->expects($this->never()) 
     130                                ->method('isSupressable'); 
     131        $this->mockErrorHandler2->expects($this->never()) 
     132                                ->method('handle'); 
     133        $this->mockErrorHandler3->expects($this->once()) 
     134                                ->method('isResponsible') 
     135                                ->will($this->returnValue(false)); 
     136        $this->mockErrorHandler3->expects($this->never()) 
     137                                ->method('isSupressable'); 
     138        $this->mockErrorHandler3->expects($this->never()) 
     139                                ->method('handle'); 
     140        $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 
     141    } 
     142 
     143    /** 
     144     * assure that handle() works correct 
     145     * 
     146     * @test 
     147     */ 
     148    public function handleWithSupressAndErrorReportingDisabled() 
    123149    { 
    124150        $oldLevel = error_reporting(0); 
    125         $this->mockErrorHandler1->setReturnValue('isResponsible', false); 
    126         $this->mockErrorHandler1->expectNever('isSupressable'); 
    127         $this->mockErrorHandler1->expectNever('handle'); 
    128         $this->mockErrorHandler2->setReturnValue('isResponsible', true); 
    129         $this->mockErrorHandler2->setReturnValue('isSupressable', true); 
    130         $this->mockErrorHandler2->expectOnce('isSupressable'); 
    131         $this->mockErrorHandler2->expectNever('handle'); 
    132         $this->mockErrorHandler3->expectNever('isResponsible'); 
    133         $this->mockErrorHandler3->expectNever('isSupressable'); 
    134         $this->mockErrorHandler3->expectNever('handle'); 
     151        $this->mockErrorHandler1->expects($this->once()) 
     152                                ->method('isResponsible') 
     153                                ->will($this->returnValue(false)); 
     154        $this->mockErrorHandler1->expects($this->never()) 
     155                                ->method('isSupressable'); 
     156        $this->mockErrorHandler1->expects($this->never()) 
     157                                ->method('handle'); 
     158        $this->mockErrorHandler2->expects($this->once()) 
     159                                ->method('isResponsible') 
     160                                ->will($this->returnValue(true)); 
     161        $this->mockErrorHandler2->expects($this->once()) 
     162                                ->method('isSupressable') 
     163                                ->will($this->returnValue(true)); 
     164        $this->mockErrorHandler2->expects($this->never()) 
     165                                ->method('handle'); 
     166        $this->mockErrorHandler3->expects($this->never()) 
     167                                ->method('isResponsible'); 
     168        $this->mockErrorHandler3->expects($this->never()) 
     169                                ->method('isSupressable'); 
     170        $this->mockErrorHandler3->expects($this->never()) 
     171                                ->method('handle'); 
    135172        $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 
    136173        error_reporting($oldLevel); 
     
    139176    /** 
    140177     * assure that handle() works correct 
    141      */ 
    142     public function testHandleWithoutSupressAndErrorReportingDisabled() 
     178     * 
     179     * @test 
     180     */ 
     181    public function handleWithoutSupressAndErrorReportingDisabled() 
    143182    { 
    144183        $oldLevel = error_reporting(0); 
    145         $this->mockErrorHandler1->setReturnValue('isResponsible', false); 
    146         $this->mockErrorHandler1->expectNever('isSupressable'); 
    147         $this->mockErrorHandler1->expectNever('handle'); 
    148         $this->mockErrorHandler2->setReturnValue('isResponsible', true); 
    149         $this->mockErrorHandler2->setReturnValue('isSupressable', false); 
    150         $this->mockErrorHandler2->setReturnValueAt(0, 'handle', true); 
    151         $this->mockErrorHandler2->setReturnValueAt(1, 'handle', false); 
    152         $this->mockErrorHandler2->expectCallcount('isSupressable', 2); 
    153         $this->mockErrorHandler2->expectCallcount('handle', 2); 
    154         $this->mockErrorHandler3->expectNever('isResponsible'); 
    155         $this->mockErrorHandler3->expectNever('isSupressable'); 
    156         $this->mockErrorHandler3->expectNever('handle'); 
     184        $this->mockErrorHandler1->expects($this->exactly(2)) 
     185                                ->method('isResponsible') 
     186                                ->will($this->returnValue(false)); 
     187        $this->mockErrorHandler1->expects($this->never()) 
     188                                ->method('isSupressable'); 
     189        $this->mockErrorHandler1->expects($this->never()) 
     190                                ->method('handle'); 
     191        $this->mockErrorHandler2->expects($this->exactly(2)) 
     192                                ->method('isResponsible') 
     193                                ->will($this->returnValue(true)); 
     194        $this->mockErrorHandler2->expects($this->exactly(2)) 
     195                                ->method('isSupressable') 
     196                                ->will($this->returnValue(false)); 
     197        $this->mockErrorHandler2->expects($this->exactly(2)) 
     198                                ->method('handle') 
     199                                ->will($this->onConsecutiveCalls(true, false)); 
     200        $this->mockErrorHandler3->expects($this->never()) 
     201                                ->method('isResponsible'); 
     202        $this->mockErrorHandler3->expects($this->never()) 
     203                                ->method('isSupressable'); 
     204        $this->mockErrorHandler3->expects($this->never()) 
     205                                ->method('handle'); 
    157206        $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 
    158207        $this->assertFalse($this->compositeErrorHandler->handle(1, 'foo')); 
     
    162211    /** 
    163212     * assure that handle() works correct 
    164      */ 
    165     public function testHandleWithErrorReportingEnabled() 
     213     * 
     214     * @test 
     215     */ 
     216    public function handleWithErrorReportingEnabled() 
    166217    { 
    167218        $oldLevel = error_reporting(E_ALL); 
    168         $this->mockErrorHandler1->setReturnValue('isResponsible', false); 
    169         $this->mockErrorHandler1->expectNever('isSupressable'); 
    170         $this->mockErrorHandler1->expectNever('handle'); 
    171         $this->mockErrorHandler2->setReturnValue('isResponsible', true); 
    172         $this->mockErrorHandler2->setReturnValueAt(0, 'handle', true); 
    173         $this->mockErrorHandler2->setReturnValueAt(1, 'handle', false); 
    174         $this->mockErrorHandler2->expectNever('isSupressable'); 
    175         $this->mockErrorHandler2->expectCallcount('handle', 2); 
    176         $this->mockErrorHandler3->expectNever('isResponsible'); 
    177         $this->mockErrorHandler3->expectNever('isSupressable'); 
    178         $this->mockErrorHandler3->expectNever('handle'); 
     219        $this->mockErrorHandler1->expects($this->exactly(2)) 
     220                                ->method('isResponsible') 
     221                                ->will($this->returnValue(false)); 
     222        $this->mockErrorHandler1->expects($this->never()) 
     223                                ->method('isSupressable'); 
     224        $this->mockErrorHandler1->expects($this->never()) 
     225                                ->method('handle'); 
     226        $this->mockErrorHandler2->expects($this->exactly(2)) 
     227                                ->method('isResponsible') 
     228                                ->will($this->returnValue(true)); 
     229        $this->mockErrorHandler2->expects($this->any()) 
     230                                ->method('isSupressable') 
     231                                ->will($this->returnValue(false)); 
     232        $this->mockErrorHandler2->expects($this->exactly(2)) 
     233                                ->method('handle') 
     234                                ->will($this->onConsecutiveCalls(true, false)); 
     235        $this->mockErrorHandler3->expects($this->never()) 
     236                                ->method('isResponsible'); 
     237        $this->mockErrorHandler3->expects($this->never()) 
     238                                ->method('isSupressable'); 
     239        $this->mockErrorHandler3->expects($this->never()) 
     240                                ->method('handle'); 
    179241        $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 
    180242        $this->assertFalse($this->compositeErrorHandler->handle(1, 'foo')); 
  • trunk/src/test/php/net/stubbles/lang/errorhandler/stubIllegalArgumentErrorHandlerTestCase.php

    r1209 r1236  
    1414 * @subpackage  lang_errorhandler_test 
    1515 */ 
    16 class stubIllegalArgumentErrorHandlerTestCase extends UnitTestCase 
     16class stubIllegalArgumentErrorHandlerTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * assure that isResponsible() works correct 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testIsResponsible() 
     38    public function isResponsible() 
    3739    { 
    3840        $this->assertFalse($this->illegalArgumentErrorHandler->isResponsible(E_NOTICE, 'foo')); 
     
    4345    /** 
    4446     * assure that isSupressable() works correct 
     47     * 
     48     * @test 
    4549     */ 
    46     public function testIsSupressable() 
     50    public function isSupressable() 
    4751    { 
    4852        $this->assertFalse($this->illegalArgumentErrorHandler->isSupressable(E_RECOVERABLE_ERROR, 'foo')); 
     
    5155    /** 
    5256     * assure that handle() works correct 
     57     * 
     58     * @test 
     59     * @expectedException  stubIllegalArgumentException 
    5360     */ 
    54     public function testHandle() 
     61    public function handle() 
    5562    { 
    56         $this->expectException('stubIllegalArgumentException'); 
    5763        $this->illegalArgumentErrorHandler->handle(E_RECOVERABLE_ERROR, 'foo'); 
    5864    } 
  • trunk/src/test/php/net/stubbles/lang/errorhandler/stubLogErrorHandlerTestCase.php

    r1209 r1236  
    88 */ 
    99stubClassLoader::load('net::stubbles::lang::errorhandler::stubLogErrorHandler'); 
    10 Mock::generate('stubSession'); 
    11  
    1210/** 
    1311 * Tests for net::stubbles::lang::errorhandler::stubLogErrorHandler. 
     
    1614 * @subpackage  lang_errorhandler_test 
    1715 */ 
    18 class stubLogErrorHandlerTestCase extends UnitTestCase 
     16class stubLogErrorHandlerTestCase extends PHPUnit_Framework_TestCase 
    1917{ 
    2018    /** 
     
    3533    /** 
    3634     * assure that isResponsible() works correct 
     35     * 
     36     * @test 
    3737     */ 
    38     public function testIsResponsible() 
     38    public function isResponsible() 
    3939    { 
    4040        $this->assertTrue($this->logErrorHandler->isResponsible(E_NOTICE, 'foo')); 
     
    4343    /** 
    4444     * assure that isSupressable() works correct 
     45     * 
     46     * @test 
    4547     */ 
    46     public function testIsSupressable() 
     48    public function isSupressable() 
    4749    { 
    4850        $this->assertFalse($this->logErrorHandler->isSupressable(E_NOTICE, 'foo')); 
  • trunk/src/test/php/net/stubbles/lang/exceptions/stubChainedExceptionTestCase.php

    r1209 r1236  
    2828 * @subpackage  lang_exceptions_test 
    2929 */ 
    30 class stubChainedExceptionTestCase extends UnitTestCase 
     30class stubChainedExceptionTestCase extends PHPUnit_Framework_TestCase 
    3131{ 
    3232    /** 
     
    4242     */ 
    4343    protected $stubChainedException2; 
    44      
     44 
    4545    /** 
    4646     * set up test environment 
     
    5151        $this->stubChainedException2 = new stub2ChainedException('This is an exception.', $this->stubChainedException1); 
    5252    } 
    53      
     53 
    5454    /** 
    5555     * assure that class name mapping works as expected 
     56     * 
     57     * @test 
    5658     */ 
    57     public function testGetCause() 
     59    public function getCause() 
    5860    { 
    5961        $this->assertNull($this->stubChainedException1->getCause()); 
    60         $this->assertReference($this->stubChainedException2->getCause(), $this->stubChainedException1); 
     62        $this->assertSame($this->stubChainedException1, $this->stubChainedException2->getCause()); 
    6163    } 
    62      
     64 
    6365    /** 
    6466     * assure that the equal() method works correct 
     67     * assure that class name mapping works as expected 
     68     * 
     69     * @test 
    6570     */ 
    66     public function testToString() 
     71    public function toString() 
    6772    { 
    68         $this->assertEqual((string) $this->stubChainedException1, "test::stub1ChainedException {\n    message(string): This is a chained exception.\n    file(string): " . __FILE__ . "\n    line(integer): 50\n    code(integer): 0\n}\n"); 
    69         $this->assertEqual((string) $this->stubChainedException2, "test::stub2ChainedException {\n    message(string): This is an exception.\n    file(string): " . __FILE__ . "\n    line(integer): 51\n    code(integer): 0\n} caused by test::stub1ChainedException {\n    message(string): This is a chained exception.\n    file(string): " . __FILE__ . "\n    line(integer): 50\n    code(integer): 0\n}\n"); 
     73        $this->assertEquals("test::stub1ChainedException {\n    message(string): This is a chained exception.\n    file(string): " . __FILE__ . "\n    line(integer): 50\n    code(integer): 0\n}\n", (string) $this->stubChainedException1); 
     74        $this->assertEquals("test::stub2ChainedException {\n    message(string): This is an exception.\n    file(string): " . __FILE__ . "\n    line(integer): 51\n    code(integer): 0\n} caused by test::stub1ChainedException {\n    message(string): This is a chained exception.\n    file(string): " . __FILE__ . "\n    line(integer): 50\n    code(integer): 0\n}\n", (string) $this->stubChainedException2); 
    7075    } 
    7176} 
  • trunk/src/test/php/net/stubbles/lang/exceptions/stubExceptionTestCase.php

    r1209 r1236  
    2828 * @subpackage  lang_exceptions_test 
    2929 */ 
    30 class stubExceptionTestCase extends UnitTestCase 
     30class stubExceptionTestCase extends PHPUnit_Framework_TestCase 
    3131{ 
    3232    /** 
     
    4242     */ 
    4343    protected $stubException2; 
    44      
     44 
    4545    /** 
    4646     * set up test environment 
     
    5151        $this->stubException2 = new stub2stubException(); 
    5252    } 
    53      
     53 
    5454    /** 
    5555     * assure that class name mapping works as expected 
     56     * 
     57     * @test 
    5658     */ 
    57     public function testGetClass() 
     59    public function getClass() 
    5860    { 
    5961        $refObject = $this->stubException1->getClass(); 
    60         $this->assertIsA($refObject, 'stubReflectionObject'); 
    61         $this->assertEqual($refObject->getName(), 'stub1stubException'); 
     62        $this->assertType('stubReflectionObject', $refObject); 
     63        $this->assertEquals('stub1stubException', $refObject->getName()); 
    6264    } 
    63      
     65 
    6466    /** 
    6567     * assure that the equal() method works correct 
     68     * 
     69     * @test 
    6670     */ 
    67     public function testEquals() 
     71    public function comparisonWithEquals() 
    6872    { 
    6973        $this->assertTrue($this->stubException1->equals($this->stubException1)); 
  • trunk/src/test/php/net/stubbles/lang/serialize/stubSerializableObjectTestCase.php

    r1209 r1236  
    3939 * @subpackage  lang_serialize_test 
    4040 */ 
    41 class stubSerializableObjectTestCase extends UnitTestCase 
     41class stubSerializableObjectTestCase extends PHPUnit_Framework_TestCase 
    4242{ 
    4343    /** 
     
    6666    /** 
    6767     * assure that serialization delivers the correct class 
     68     * 
     69     * @test 
    6870     */ 
    69     public function testGetSerialized() 
     71    public function getSerialized() 
    7072    { 
    7173        $serialized = $this->stubSerializableObject1->getSerialized(); 
    72         $this->assertIsA($serialized, 'stubSerializedObject'); 
     74        $this->assertType('stubSerializedObject', $serialized); 
    7375    } 
    7476 
    7577    /** 
    7678     * assure that the __toString() method works correct 
     79     * 
     80     * @test 
    7781     */ 
    78     public function testToString() 
     82    public function toString() 
    7983    { 
    80         $this->assertEqual((string) $this->stubSerializableObject1, "test::stub1stubSerializableObject {\n    bar(integer): 5\n}\n"); 
    81         $this->assertEqual((string) $this->stubSerializableObject2, "test::stub2stubSerializableObject {\n    stubSerializableObject(test::stub1stubSerializableObject): test::stub1stubSerializableObject {\n        bar(integer): 5\n    }\n    foo(string): bar\n}\n"); 
     84        $this->assertEquals("test::stub1stubSerializableObject {\n    bar(integer): 5\n}\n", (string) $this->stubSerializableObject1); 
     85        $this->assertEquals("test::stub2stubSerializableObject {\n    stubSerializableObject(test::stub1stubSerializableObject): test::stub1stubSerializableObject {\n        bar(integer): 5\n    }\n    foo(string): bar\n}\n", (string) $this->stubSerializableObject2); 
    8286    } 
    8387 
    8488    /** 
    8589     * assure that the __sleep() method works correct 
     90     * 
     91     * @test 
    8692     */ 
    87     public function testSleep() 
     93    public function sleep() 
    8894    { 
    89         $this->assertEqual($this->stubSerializableObject2->__sleep(), array('foo', '_serializedProperties')); 
     95        $this->assertEquals(array('foo', '_serializedProperties'), $this->stubSerializableObject2->__sleep()); 
    9096        $serializedProperties = $this->stubSerializableObject2->getSerializedProperties(); 
    9197        $this->assertTrue(isset($serializedProperties['stubSerializableObject'])); 
    92         $this->assertIsA($serializedProperties['stubSerializableObject'], 'stubSerializedObject'); 
    93         $this->assertEqual($serializedProperties['stubSerializableObject']->getSerializedClassName(), 'test::stub1stubSerializableObject'); 
     98        $this->assertType('stubSerializedObject', $serializedProperties['stubSerializableObject']); 
     99        $this->assertEquals('test::stub1stubSerializableObject', $serializedProperties['stubSerializableObject']->getSerializedClassName()); 
    94100    } 
    95101} 
  • trunk/src/test/php/net/stubbles/lang/serialize/stubSerializedObjectTestCase.php

    r1209 r1236  
    3333 * @subpackage  lang_serialize_test 
    3434 */ 
    35 class stubSerializedObjectTestCase extends UnitTestCase 
     35class stubSerializedObjectTestCase extends PHPUnit_Framework_TestCase 
    3636{ 
    3737    /** 
     
    6060    /** 
    6161     * assert that default values are as expected 
     62     * 
     63     * @test 
    6264     */ 
    63     public function testValues() 
     65    public function values() 
    6466    { 
    65         $this->assertEqual($this->serializedObject->getSerializedClassName(), 'test::stub3stubSerializableObject'); 
     67        $this->assertEquals('test::stub3stubSerializableObject', $this->serializedObject->getSerializedClassName()); 
    6668    } 
    6769 
    6870    /** 
    6971     * assure that unserialize works as expected 
     72     * 
     73     * @test 
    7074     */ 
    71     public function testUnserialize() 
     75    public function unserialize() 
    7276    { 
    7377        $restored = $this->serializedObject->getUnserialized(); 
    74         $this->assertIsA($restored, 'stub3stubSerializableObject'); 
    75         $this->assertEqual($restored->getBar(), 313); 
     78        $this->assertType('stub3stubSerializableObject', $restored); 
     79        $this->assertEquals(313, $restored->getBar()); 
    7680    } 
    7781 
    7882    /** 
    7983     * assure that class name mapping works as expected 
     84     * 
     85     * @test 
    8086     */ 
    81     public function testGetClassName() 
     87    public function getClass() 
    8288    { 
    8389        $refObject = $this->serializedObject->getClass(); 
    84         $this->assertIsA($refObject, 'stubReflectionObject'); 
    85         $this->assertEqual($refObject->getName(), 'stubSerializedObject'); 
     90        $this->assertType('stubReflectionObject', $refObject); 
     91        $this->assertEquals('stubSerializedObject', $refObject->getName()); 
    8692    } 
    8793 
    8894    /** 
    8995     * assure that the equal() method works correct 
     96     * 
     97     * @test 
    9098     */ 
    91     public function testEquals() 
     99    public function comparisonwithEquals() 
    92100    { 
    93101        $this->assertTrue($this->serializedObject->equals($this->serializedObject)); 
     
    104112    /** 
    105113     * assure that serialization throws an exception 
     114     * 
     115     * @test 
     116     * @expectedException  Exception 
    106117     */ 
    107     public function testGetSerialized() 
     118    public function getSerialized() 
    108119    { 
    109         $this->expectException('Exception'); 
    110120        $this->serializedObject->getSerialized(); 
    111121    } 
     
    113123    /** 
    114124     * assure that the __toString() method works correct 
     125     * 
     126     * @test 
    115127     */ 
    116     public function testToString() 
     128    public function toString() 
    117129    { 
    118         $this->assertEqual((string) $this->serializedObject, "net::stubbles::lang::serialize::stubSerializedObject {\n    fqClassName(string): test::stub3stubSerializableObject\n    nqClassName(string): stub3stubSerializableObject\n    data(string): " . serialize($this->stubSerializableObject) . "\n}\n"); 
     130        $this->assertEquals("net::stubbles::lang::serialize::stubSerializedObject {\n    fqClassName(string): test::stub3stubSerializableObject\n    nqClassName(string): stub3stubSerializableObject\n    data(string): " . serialize($this->stubSerializableObject) . "\n}\n", (string) $this->serializedObject); 
    119131    } 
    120132 
    121133    /** 
    122134     * assure that changes to the serialized object are not thrown away 
     135     * 
     136     * @test 
    123137     */ 
    124     public function testDataIntegrity() 
     138    public function dataIntegrity() 
    125139    { 
    126140        $stub3 = $this->serializedObject->getUnserialized(); 
    127         $this->assertReference($stub3, $this->stubSerializableObject); 
     141        $this->assertSame($this->stubSerializableObject, $stub3); 
    128142        $this->stubSerializableObject->setBar(303); 
    129143         
     
    132146        $stub3b = $newSerializedObject->getUnserialized(); 
    133147        $stub3c = $newSerializedObject->getUnserialized(); 
    134         $this->assertReference($stub3b, $stub3c); 
    135         $this->assertEqual($stub3b->getBar(), 303); 
     148        $this->assertSame($stub3b, $stub3c); 
     149        $this->assertEquals(303, $stub3b->getBar()); 
    136150        $stub3b->setBar(909); 
    137151         
     
    139153        $moreSerializedObject = unserialize(serialize($this->serializedObject)); 
    140154        $stub3d = $newSerializedObject->getUnserialized(); 
    141         $this->assertEqual($stub3d->getBar(), 909); 
     155        $this->assertEquals(909, $stub3d->getBar()); 
    142156    } 
    143157 
     
    145159     * test against bug: ensure that the integrity of the serialized object 
    146160     * is maintained over several serialize/unserialize operations 
     161     * 
     162     * @test 
    147163