Changeset 1236
- Timestamp:
- 01/14/08 00:02:35 (8 months ago)
- Files:
-
- trunk/src/test/AllTests.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/lang/errorhandler/stubAbstractExceptionHandlerTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/lang/errorhandler/stubCompositeErrorHandlerTestCase.php (modified) (12 diffs)
- trunk/src/test/php/net/stubbles/lang/errorhandler/stubIllegalArgumentErrorHandlerTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/lang/errorhandler/stubLogErrorHandlerTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/lang/exceptions/stubChainedExceptionTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/lang/exceptions/stubExceptionTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/lang/serialize/stubSerializableObjectTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/lang/serialize/stubSerializedObjectTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/lang/stubBaseObjectTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/lang/stubEnumTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/lang/stubModeTestCase.php (modified) (13 diffs)
- trunk/src/test/php/net/stubbles/stubTestSuite.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/test/AllTests.php
r1235 r1236 22 22 PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/org'); 23 23 24 require_once $dir . '/php/net/stubbles/stubTestSuite.php'; 24 25 require_once $dir . '/php/net/stubbles/auth/AuthTestSuite.php'; 25 26 require_once $dir . '/php/net/stubbles/events/EventTestSuite.php'; … … 48 49 public static function suite() 49 50 { 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'); 54 53 $suite->addTestSuite('AuthTestSuite'); 55 54 $suite->addTestSuite('EventTestSuite'); trunk/src/test/php/net/stubbles/lang/errorhandler/stubAbstractExceptionHandlerTestCase.php
r1209 r1236 11 11 'net::stubbles::util::log::stubMemoryLogAppender' 12 12 ); 13 Mock::generate('stubSession');14 Mock::generatePartial('stubAbstractExceptionHandler', 'PartialMock1stubAbstractExceptionHandler', array('fillResponse'));15 Mock::generatePartial('stubAbstractExceptionHandler', 'PartialMock2stubAbstractExceptionHandler', array('fillResponse', 'log'));16 13 /** 17 14 * Chained exception for test purposes. … … 38 35 * @subpackage lang_errorhandler_test 39 36 */ 40 class stubAbstractExceptionHandlerTestCase extends UnitTestCase37 class stubAbstractExceptionHandlerTestCase extends PHPUnit_Framework_TestCase 41 38 { 42 39 /** … … 52 49 public function setUp() 53 50 { 54 $this->abstractExceptionHandler = new PartialMock1stubAbstractExceptionHandler();51 $this->abstractExceptionHandler = $this->getMock('stubAbstractExceptionHandler', array('fillResponse')); 55 52 stubRegistry::setConfig('net.stubbles.util.log.class', 'net::stubbles::util::log::stubBaseLogData'); 56 53 $binder = new stubBinder(); … … 74 71 /** 75 72 * assure that disabling logging works correct 73 * 74 * @test 76 75 */ 77 public function LoggingDisabled()76 public function loggingDisabled() 78 77 { 79 $abstractExceptionHandler = new PartialMock2stubAbstractExceptionHandler();80 $abstractExceptionHandler->expect Never('log');78 $abstractExceptionHandler = $this->getMock('stubAbstractExceptionHandler', array('fillResponse', 'log')); 79 $abstractExceptionHandler->expects($this->never())->method('log'); 81 80 $abstractExceptionHandler->setLogging(false); 82 81 $abstractExceptionHandler->handleException(new Exception()); … … 85 84 /** 86 85 * assure that the exception is logged 86 * 87 * @test 87 88 */ 88 public function testHandleException()89 public function handleException() 89 90 { 90 91 $logger = stubLogger::getInstance(__CLASS__); … … 94 95 $line = __LINE__ - 1; 95 96 $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()); 100 101 $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]); 109 110 stubLogger::destroyInstance(__CLASS__); 110 111 } … … 112 113 /** 113 114 * assure that the exception is logged 115 * 116 * @test 114 117 */ 115 public function testHandleChainedException()118 public function handleChainedException() 116 119 { 117 120 $logger = stubLogger::getInstance(__CLASS__); … … 124 127 $this->abstractExceptionHandler->handleException($exception); 125 128 $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()); 130 133 $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]); 139 142 stubLogger::destroyInstance(__CLASS__); 140 143 } trunk/src/test/php/net/stubbles/lang/errorhandler/stubCompositeErrorHandlerTestCase.php
r1209 r1236 8 8 */ 9 9 stubClassLoader::load('net::stubbles::lang::errorhandler::stubCompositeErrorHandler'); 10 Mock::generate('stubErrorHandler');11 10 /** 12 11 * Tests for net::stubbles::lang::errorhandler::stubCompositeErrorHandler … … 15 14 * @subpackage lang_errorhandler_test 16 15 */ 17 class stubCompositeErrorHandlerTestCase extends UnitTestCase16 class stubCompositeErrorHandlerTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 26 25 * a mocked error handler 27 26 * 28 * @var SimpleMock27 * @var PHPUnit_Framework_MockObject_MockObject 29 28 */ 30 29 protected $mockErrorHandler1; … … 32 31 * a mocked error handler 33 32 * 34 * @var SimpleMock33 * @var PHPUnit_Framework_MockObject_MockObject 35 34 */ 36 35 protected $mockErrorHandler2; … … 38 37 * a mocked error handler 39 38 * 40 * @var SimpleMock39 * @var PHPUnit_Framework_MockObject_MockObject 41 40 */ 42 41 protected $mockErrorHandler3; … … 48 47 { 49 48 $this->compositeErrorHandler = new stubCompositeErrorHandler(); 50 $this->mockErrorHandler1 = new MockstubErrorHandler();49 $this->mockErrorHandler1 = $this->getMock('stubErrorHandler'); 51 50 $this->compositeErrorHandler->addErrorHandler($this->mockErrorHandler1); 52 $this->mockErrorHandler2 = new MockstubErrorHandler();51 $this->mockErrorHandler2 = $this->getMock('stubErrorHandler'); 53 52 $this->compositeErrorHandler->addErrorHandler($this->mockErrorHandler2); 54 $this->mockErrorHandler3 = new MockstubErrorHandler();53 $this->mockErrorHandler3 = $this->getMock('stubErrorHandler'); 55 54 $this->compositeErrorHandler->addErrorHandler($this->mockErrorHandler3); 56 55 } … … 58 57 /** 59 58 * 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() 67 69 ); 68 70 } … … 70 72 /** 71 73 * 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)); 82 88 $this->assertTrue($this->compositeErrorHandler->isResponsible(1, 'foo')); 83 89 $this->assertFalse($this->compositeErrorHandler->isResponsible(1, 'foo')); … … 86 92 /** 87 93 * 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)); 98 108 $this->assertFalse($this->compositeErrorHandler->isSupressable(1, 'foo')); 99 109 $this->assertTrue($this->compositeErrorHandler->isSupressable(1, 'foo')); … … 102 112 /** 103 113 * 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() 123 149 { 124 150 $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'); 135 172 $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 136 173 error_reporting($oldLevel); … … 139 176 /** 140 177 * assure that handle() works correct 141 */ 142 public function testHandleWithoutSupressAndErrorReportingDisabled() 178 * 179 * @test 180 */ 181 public function handleWithoutSupressAndErrorReportingDisabled() 143 182 { 144 183 $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'); 157 206 $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 158 207 $this->assertFalse($this->compositeErrorHandler->handle(1, 'foo')); … … 162 211 /** 163 212 * assure that handle() works correct 164 */ 165 public function testHandleWithErrorReportingEnabled() 213 * 214 * @test 215 */ 216 public function handleWithErrorReportingEnabled() 166 217 { 167 218 $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'); 179 241 $this->assertTrue($this->compositeErrorHandler->handle(1, 'foo')); 180 242 $this->assertFalse($this->compositeErrorHandler->handle(1, 'foo')); trunk/src/test/php/net/stubbles/lang/errorhandler/stubIllegalArgumentErrorHandlerTestCase.php
r1209 r1236 14 14 * @subpackage lang_errorhandler_test 15 15 */ 16 class stubIllegalArgumentErrorHandlerTestCase extends UnitTestCase16 class stubIllegalArgumentErrorHandlerTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * assure that isResponsible() works correct 35 * 36 * @test 35 37 */ 36 public function testIsResponsible()38 public function isResponsible() 37 39 { 38 40 $this->assertFalse($this->illegalArgumentErrorHandler->isResponsible(E_NOTICE, 'foo')); … … 43 45 /** 44 46 * assure that isSupressable() works correct 47 * 48 * @test 45 49 */ 46 public function testIsSupressable()50 public function isSupressable() 47 51 { 48 52 $this->assertFalse($this->illegalArgumentErrorHandler->isSupressable(E_RECOVERABLE_ERROR, 'foo')); … … 51 55 /** 52 56 * assure that handle() works correct 57 * 58 * @test 59 * @expectedException stubIllegalArgumentException 53 60 */ 54 public function testHandle()61 public function handle() 55 62 { 56 $this->expectException('stubIllegalArgumentException');57 63 $this->illegalArgumentErrorHandler->handle(E_RECOVERABLE_ERROR, 'foo'); 58 64 } trunk/src/test/php/net/stubbles/lang/errorhandler/stubLogErrorHandlerTestCase.php
r1209 r1236 8 8 */ 9 9 stubClassLoader::load('net::stubbles::lang::errorhandler::stubLogErrorHandler'); 10 Mock::generate('stubSession');11 12 10 /** 13 11 * Tests for net::stubbles::lang::errorhandler::stubLogErrorHandler. … … 16 14 * @subpackage lang_errorhandler_test 17 15 */ 18 class stubLogErrorHandlerTestCase extends UnitTestCase16 class stubLogErrorHandlerTestCase extends PHPUnit_Framework_TestCase 19 17 { 20 18 /** … … 35 33 /** 36 34 * assure that isResponsible() works correct 35 * 36 * @test 37 37 */ 38 public function testIsResponsible()38 public function isResponsible() 39 39 { 40 40 $this->assertTrue($this->logErrorHandler->isResponsible(E_NOTICE, 'foo')); … … 43 43 /** 44 44 * assure that isSupressable() works correct 45 * 46 * @test 45 47 */ 46 public function testIsSupressable()48 public function isSupressable() 47 49 { 48 50 $this->assertFalse($this->logErrorHandler->isSupressable(E_NOTICE, 'foo')); trunk/src/test/php/net/stubbles/lang/exceptions/stubChainedExceptionTestCase.php
r1209 r1236 28 28 * @subpackage lang_exceptions_test 29 29 */ 30 class stubChainedExceptionTestCase extends UnitTestCase30 class stubChainedExceptionTestCase extends PHPUnit_Framework_TestCase 31 31 { 32 32 /** … … 42 42 */ 43 43 protected $stubChainedException2; 44 44 45 45 /** 46 46 * set up test environment … … 51 51 $this->stubChainedException2 = new stub2ChainedException('This is an exception.', $this->stubChainedException1); 52 52 } 53 53 54 54 /** 55 55 * assure that class name mapping works as expected 56 * 57 * @test 56 58 */ 57 public function testGetCause()59 public function getCause() 58 60 { 59 61 $this->assertNull($this->stubChainedException1->getCause()); 60 $this->assert Reference($this->stubChainedException2->getCause(), $this->stubChainedException1);62 $this->assertSame($this->stubChainedException1, $this->stubChainedException2->getCause()); 61 63 } 62 64 63 65 /** 64 66 * assure that the equal() method works correct 67 * assure that class name mapping works as expected 68 * 69 * @test 65 70 */ 66 public function t estToString()71 public function toString() 67 72 { 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); 70 75 } 71 76 } trunk/src/test/php/net/stubbles/lang/exceptions/stubExceptionTestCase.php
r1209 r1236 28 28 * @subpackage lang_exceptions_test 29 29 */ 30 class stubExceptionTestCase extends UnitTestCase30 class stubExceptionTestCase extends PHPUnit_Framework_TestCase 31 31 { 32 32 /** … … 42 42 */ 43 43 protected $stubException2; 44 44 45 45 /** 46 46 * set up test environment … … 51 51 $this->stubException2 = new stub2stubException(); 52 52 } 53 53 54 54 /** 55 55 * assure that class name mapping works as expected 56 * 57 * @test 56 58 */ 57 public function testGetClass()59 public function getClass() 58 60 { 59 61 $refObject = $this->stubException1->getClass(); 60 $this->assert IsA($refObject, 'stubReflectionObject');61 $this->assertEqual ($refObject->getName(), 'stub1stubException');62 $this->assertType('stubReflectionObject', $refObject); 63 $this->assertEquals('stub1stubException', $refObject->getName()); 62 64 } 63 65 64 66 /** 65 67 * assure that the equal() method works correct 68 * 69 * @test 66 70 */ 67 public function testEquals()71 public function comparisonWithEquals() 68 72 { 69 73 $this->assertTrue($this->stubException1->equals($this->stubException1)); trunk/src/test/php/net/stubbles/lang/serialize/stubSerializableObjectTestCase.php
r1209 r1236 39 39 * @subpackage lang_serialize_test 40 40 */ 41 class stubSerializableObjectTestCase extends UnitTestCase41 class stubSerializableObjectTestCase extends PHPUnit_Framework_TestCase 42 42 { 43 43 /** … … 66 66 /** 67 67 * assure that serialization delivers the correct class 68 * 69 * @test 68 70 */ 69 public function testGetSerialized()71 public function getSerialized() 70 72 { 71 73 $serialized = $this->stubSerializableObject1->getSerialized(); 72 $this->assert IsA($serialized, 'stubSerializedObject');74 $this->assertType('stubSerializedObject', $serialized); 73 75 } 74 76 75 77 /** 76 78 * assure that the __toString() method works correct 79 * 80 * @test 77 81 */ 78 public function t estToString()82 public function toString() 79 83 { 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); 82 86 } 83 87 84 88 /** 85 89 * assure that the __sleep() method works correct 90 * 91 * @test 86 92 */ 87 public function testSleep()93 public function sleep() 88 94 { 89 $this->assertEqual ($this->stubSerializableObject2->__sleep(), array('foo', '_serializedProperties'));95 $this->assertEquals(array('foo', '_serializedProperties'), $this->stubSerializableObject2->__sleep()); 90 96 $serializedProperties = $this->stubSerializableObject2->getSerializedProperties(); 91 97 $this->assertTrue(isset($serializedProperties['stubSerializableObject'])); 92 $this->assert IsA($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()); 94 100 } 95 101 } trunk/src/test/php/net/stubbles/lang/serialize/stubSerializedObjectTestCase.php
r1209 r1236 33 33 * @subpackage lang_serialize_test 34 34 */ 35 class stubSerializedObjectTestCase extends UnitTestCase35 class stubSerializedObjectTestCase extends PHPUnit_Framework_TestCase 36 36 { 37 37 /** … … 60 60 /** 61 61 * assert that default values are as expected 62 * 63 * @test 62 64 */ 63 public function testValues()65 public function values() 64 66 { 65 $this->assertEqual ($this->serializedObject->getSerializedClassName(), 'test::stub3stubSerializableObject');67 $this->assertEquals('test::stub3stubSerializableObject', $this->serializedObject->getSerializedClassName()); 66 68 } 67 69 68 70 /** 69 71 * assure that unserialize works as expected 72 * 73 * @test 70 74 */ 71 public function testUnserialize()75 public function unserialize() 72 76 { 73 77 $restored = $this->serializedObject->getUnserialized(); 74 $this->assert IsA($restored, 'stub3stubSerializableObject');75 $this->assertEqual ($restored->getBar(), 313);78 $this->assertType('stub3stubSerializableObject', $restored); 79 $this->assertEquals(313, $restored->getBar()); 76 80 } 77 81 78 82 /** 79 83 * assure that class name mapping works as expected 84 * 85 * @test 80 86 */ 81 public function testGetClassName()87 public function getClass() 82 88 { 83 89 $refObject = $this->serializedObject->getClass(); 84 $this->assert IsA($refObject, 'stubReflectionObject');85 $this->assertEqual ($refObject->getName(), 'stubSerializedObject');90 $this->assertType('stubReflectionObject', $refObject); 91 $this->assertEquals('stubSerializedObject', $refObject->getName()); 86 92 } 87 93 88 94 /** 89 95 * assure that the equal() method works correct 96 * 97 * @test 90 98 */ 91 public function testEquals()99 public function comparisonwithEquals() 92 100 { 93 101 $this->assertTrue($this->serializedObject->equals($this->serializedObject)); … … 104 112 /** 105 113 * assure that serialization throws an exception 114 * 115 * @test 116 * @expectedException Exception 106 117 */ 107 public function testGetSerialized()118 public function getSerialized() 108 119 { 109 $this->expectException('Exception');110 120 $this->serializedObject->getSerialized(); 111 121 } … … 113 123 /** 114 124 * assure that the __toString() method works correct 125 * 126 * @test 115 127 */ 116 public function t estToString()128 public function toString() 117 129 { 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); 119 131 } 120 132 121 133 /** 122 134 * assure that changes to the serialized object are not thrown away 135 * 136 * @test 123 137 */ 124 public function testDataIntegrity()138 public function dataIntegrity() 125 139 { 126 140 $stub3 = $this->serializedObject->getUnserialized(); 127 $this->assert Reference($stub3, $this->stubSerializableObject);141 $this->assertSame($this->stubSerializableObject, $stub3); 128 142 $this->stubSerializableObject->setBar(303); 129 143 … … 132 146 $stub3b = $newSerializedObject->getUnserialized(); 133 147 $stub3c = $newSerializedObject->getUnserialized(); 134 $this->assert Reference($stub3b, $stub3c);135 $this->assertEqual ($stub3b->getBar(), 303);148 $this->assertSame($stub3b, $stub3c); 149 $this->assertEquals(303, $stub3b->getBar()); 136 150 $stub3b->setBar(909); 137 151 … … 139 153 $moreSerializedObject = unserialize(serialize($this->serializedObject)); 140 154 $stub3d = $newSerializedObject->getUnserialized(); 141 $this->assertEqual ($stub3d->getBar(), 909);155 $this->assertEquals(909, $stub3d->getBar()); 142 156 } 143 157 … … 145 159 * test against bug: ensure that the integrity of the serialized object 146 160 * is maintained over several serialize/unserialize operations 161 * 162 * @test 147 163
