Changeset 1235
- Timestamp:
- 01/13/08 22:42:50 (8 months ago)
- Files:
-
- trunk/build.xml (modified) (1 diff)
- trunk/build/stubbles/build.xml (modified) (2 diffs)
- trunk/build/stubbles/reports (added)
- trunk/build/stubbles/reports/coverage (added)
- trunk/src/main/php/net/stubbles/auth/strategy/stubAuthFailOverStrategy.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/auth/strategy/stubAuthOrStrategy.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/stubClassLoader.php (modified) (1 diff)
- trunk/src/test/AllTests.php (added)
- trunk/src/test/php/net/stubbles/auth/AuthTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/auth/storage/stubAuthSessionStorageTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/auth/strategy/stubAuthFailOverStrategyTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/auth/strategy/stubAuthOrStrategyTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/auth/strategy/stubAuthStrategyBaseTestCase.php (modified) (6 diffs)
- trunk/src/test/php/net/stubbles/auth/stubAuthTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/events/EventTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/events/stubCallbackListenerTestCase.php (modified) (15 diffs)
- trunk/src/test/php/net/stubbles/events/stubEventDispatcherTestCase.php (modified) (24 diffs)
- trunk/src/test/php/net/stubbles/events/stubEventTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/events/stubLazyEventListenerTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/events/stubNonCancelableEventTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/annotations/stubImplementedByAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/annotations/stubInjectAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/annotations/stubNamedAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/annotations/stubSingletonAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/stubBinderTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/stubIOCPreInterceptorTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorBasicTestCase.php (modified) (11 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorConstantTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorImplementedByTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorNamedTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorSingletonTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/stubClassLoaderTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/stubTestSuite.php (modified) (1 diff)
- trunk/src/test/run.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build.xml
r1152 r1235 37 37 <else> 38 38 <phing phingfile="${build.base.dir}/stubbles/build.xml" target="test" /> 39 </else> 40 </if> 41 </target> 42 43 <target name="test-new" description="run test suite"> 44 <if> 45 <isset property="package" /> 46 <then> 47 <phing phingfile="${build.base.dir}/${package}/build.xml" target="test-new" /> 48 </then> 49 <else> 50 <phing phingfile="${build.base.dir}/stubbles/build.xml" target="test-new" /> 39 51 </else> 40 52 </if> trunk/build/stubbles/build.xml
r1218 r1235 2 2 <project name="stubbles" default="main"> 3 3 <property name="build.base.dir" value="${stubbles.base.dir}/build/stubbles/build" override="true"/> 4 <property name="build.report.dir" value="${stubbles.base.dir}/build/stubbles/reports" override="true"/> 4 5 <property name="pkg.dir" value="${stubbles.base.dir}/src/main/php/net/stubbles" /> 5 6 <property name="pkg.name" value="stubbles-${version}"/> … … 217 218 </target> 218 219 220 <target name="test-new" description="run test suite"> 221 <delete> 222 <fileset dir="${build.report.dir}"> 223 <include name="**"/> 224 </fileset> 225 </delete> 226 <phingcall target="test-preparation" /> 227 <exec passthru="true" command="phpunit --log-metrics ${build.report.dir}/metrics.xml --log-pmd ${build.report.dir}/pmd.xml --coverage-html ${build.report.dir}/coverage src_test_AllTests"/> 228 </target> 229 219 230 <target name="test-integration"> 220 231 <phingcall target="test-preparation" /> trunk/src/main/php/net/stubbles/auth/strategy/stubAuthFailOverStrategy.php
r1209 r1235 36 36 $result = $authenticator->authenticate($credentials); 37 37 if ($result->getStatus() != stubAuthResult::STATUS_AUTHENTICATOR_FAILURE) { 38 break;38 return $result; 39 39 } 40 40 } trunk/src/main/php/net/stubbles/auth/strategy/stubAuthOrStrategy.php
r1209 r1235 32 32 $result = $authenticator->authenticate($credentials); 33 33 if ($result->getStatus() == stubAuthResult::STATUS_SUCCESS) { 34 break;34 return $result; 35 35 } 36 36 } trunk/src/main/php/net/stubbles/stubClassLoader.php
r1214 r1235 212 212 } 213 213 214 if (( include_once $uri) === false) {214 if ((@include_once $uri) === false) { 215 215 throw new stubClassNotFoundException($fqClassName); 216 216 } trunk/src/test/php/net/stubbles/auth/AuthTestSuite.php
r756 r1235 13 13 * @subpackage test 14 14 */ 15 class AuthTestSuite extends TestSuite15 class AuthTestSuite extends PHPUnit_Framework_TestSuite 16 16 { 17 17 /** 18 * constructor 18 * returns the test suite to be run 19 * 20 * @return PHPUnit_Framework_TestSuite 19 21 */ 20 public function __construct()22 public static function suite() 21 23 { 22 $dir = dirname(__FILE__); 23 $this->TestSuite('All auth tests'); 24 $this->addTestFile($dir . '/stubAuthTestCase.php'); 25 $this->addTestFile($dir . '/storage/stubAuthSessionStorageTestCase.php'); 26 $this->addTestFile($dir . '/strategy/stubAuthFailOverStrategyTestCase.php'); 27 $this->addTestFile($dir . '/strategy/stubAuthOrStrategyTestCase.php'); 24 $suite = new self(); 25 $dir = dirname(__FILE__); 26 $suite->addTestFile($dir . '/stubAuthTestCase.php'); 27 $suite->addTestFile($dir . '/storage/stubAuthSessionStorageTestCase.php'); 28 $suite->addTestFile($dir . '/strategy/stubAuthFailOverStrategyTestCase.php'); 29 $suite->addTestFile($dir . '/strategy/stubAuthOrStrategyTestCase.php'); 30 return $suite; 28 31 } 29 32 } trunk/src/test/php/net/stubbles/auth/storage/stubAuthSessionStorageTestCase.php
r1209 r1235 8 8 */ 9 9 stubClassLoader::load('net::stubbles::auth::storage::stubAuthSessionStorage'); 10 Mock::generate('stubSession');11 10 /** 12 11 * Tests for net::stubbles::auth::storage::stubAuthSessionStorage. … … 15 14 * @subpackage auth_storage_test 16 15 */ 17 class stubAuthSessionStorageTestCase extends UnitTestCase16 class stubAuthSessionStorageTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 26 25 * a mocked session 27 26 * 28 * @var SimpleMock27 * @var PHPUnit_Framework_MockObject_MockObject 29 28 */ 30 29 protected $session; … … 35 34 public function setup() 36 35 { 37 $this->session = new MockstubSession();36 $this->session = $this->getMock('stubSession'); 38 37 $this->storage = new stubAuthSessionStorage($this->session); 39 38 } … … 41 40 /** 42 41 * assure that validity of storage works as expected 42 * 43 * @test 43 44 */ 44 public function testIsValid()45 public function isValidWhenAuthResultIsSuccessAndTimeoutNotReached() 45 46 { 46 47 $authResult1 = new stubAuthResult(stubAuthResult::STATUS_CREDENTIALS_INVALID, 'foo'); 47 48 $authResult2 = new stubAuthResult(stubAuthResult::STATUS_SUCCESS, 'foo'); 48 $this->session->setReturnValueAt(0, 'getValue', null); 49 $this->session->setReturnValueAt(1, 'getValue', $authResult1); 50 $this->session->setReturnValueAt(2, 'getValue', $authResult2); 51 $this->session->setReturnValueAt(3, 'getValue', (time() - 3601)); 52 $this->session->setReturnValueAt(4, 'getValue', $authResult2); 53 $this->session->setReturnValueAt(5, 'getValue', (time() - 3600)); 54 $this->session->setReturnValueAt(6, 'getValue', $authResult2); 55 $this->session->setReturnValueAt(7, 'getValue', (time() - 3599)); 49 $this->session->expects($this->exactly(10)) 50 ->method('getValue') 51 ->will($this->onConsecutiveCalls(null, 52 $authResult1, 53 $authResult2, 54 (time() - 3601), 55 $authResult2, 56 (time() - 3600), 57 $authResult2, 58 (time() - 3599), 59 $authResult2, 60 (time() - 3599) 61 ) 62 ); 56 63 $this->assertFalse($this->storage->isValid()); 57 64 $this->assertFalse($this->storage->isValid()); … … 59 66 $this->assertTrue($this->storage->isValid()); 60 67 $this->assertTrue($this->storage->isValid()); 68 $this->storage->setTimeout(3598); 69 $this->assertFalse($this->storage->isValid()); 61 70 } 62 71 63 72 /** 64 73 * assure that session id is regenerated when setting new result 74 * 75 * @test 65 76 */ 66 public function testSetResult()77 public function setResult() 67 78 { 68 $this->session->expect Once('regenerateId');79 $this->session->expects($this->once())->method('regenerateId'); 69 80 $authResult = new stubAuthResult(stubAuthResult::STATUS_CREDENTIALS_INVALID, 'foo'); 70 81 $this->storage->setResult($authResult); … … 73 84 /** 74 85 * assure that session id is regenerated when clearing authentication result 86 * 87 * @test 75 88 */ 76 public function testClear()89 public function clear() 77 90 { 78 $this->session->expect Once('regenerateId');91 $this->session->expects($this->once())->method('regenerateId'); 79 92 $this->storage->clear(); 80 93 } … … 82 95 /** 83 96 * assure that retrieving the auth data works as expected 97 * 98 * @test 84 99 */ 85 public function testGetAuthData()100 public function getAuthData() 86 101 { 87 $this->session->setReturnValueAt(0, 'getValue', null);88 102 $authResult = new stubAuthResult(stubAuthResult::STATUS_SUCCESS, 'foo', 'authData'); 89 $this->session->setReturnValueAt(1, 'getValue', $authResult); 103 $this->session->expects($this->exactly(2)) 104 ->method('getValue') 105 ->will($this->onConsecutiveCalls(null, $authResult)); 90 106 $this->assertNull($this->storage->getAuthData()); 91 $this->assertEqual ($this->storage->getAuthData(), 'authData');107 $this->assertEquals('authData', $this->storage->getAuthData()); 92 108 } 93 109 } trunk/src/test/php/net/stubbles/auth/strategy/stubAuthFailOverStrategyTestCase.php
r1209 r1235 27 27 /** 28 28 * assure that strategy works as expected 29 * 30 * @test 29 31 */ 30 public function testSuccess()32 public function success() 31 33 { 32 34 $authenticators = array($this->authenticatorSuccess, $this->authenticatorInvalid, $this->authenticatorFailure); 33 $this->authenticatorInvalid->expect Never('authenticate');34 $this->authenticatorFailure->expect Never('authenticate');35 $this->authenticatorInvalid->expects($this->never())->method('authenticate'); 36 $this->authenticatorFailure->expects($this->never())->method('authenticate'); 35 37 $result = $this->strategy->authenticate($authenticators, 'foo'); 36 $this->assert Reference($this->resultSuccess, $result);38 $this->assertSame($this->resultSuccess, $result); 37 39 } 38 40 39 41 /** 40 42 * assure that strategy works as expected 43 * 44 * @test 41 45 */ 42 public function testNoSuccess()46 public function noSuccess() 43 47 { 44 48 $authenticators = array($this->authenticatorInvalid, $this->authenticatorSuccess, $this->authenticatorFailure); 45 $this->authenticatorSuccess->expect Never('authenticate');46 $this->authenticatorFailure->expect Never('authenticate');49 $this->authenticatorSuccess->expects($this->never())->method('authenticate'); 50 $this->authenticatorFailure->expects($this->never())->method('authenticate'); 47 51 $result = $this->strategy->authenticate($authenticators, 'foo'); 48 $this->assert Reference($this->resultInvalid, $result);52 $this->assertSame($this->resultInvalid, $result); 49 53 } 50 54 51 55 /** 52 56 * assure that strategy works as expected 57 * 58 * @test 53 59 */ 54 public function testFailoverWithSuccess()60 public function failoverWithSuccess() 55 61 { 56 62 $authenticators = array($this->authenticatorFailure, $this->authenticatorSuccess, $this->authenticatorInvalid); 57 $this->authenticatorSuccess->expect Once('authenticate');58 $this->authenticatorInvalid->expect Never('authenticate');63 $this->authenticatorSuccess->expects($this->once())->method('authenticate')->will($this->returnValue($this->resultSuccess)); 64 $this->authenticatorInvalid->expects($this->never())->method('authenticate'); 59 65 $result = $this->strategy->authenticate($authenticators, 'foo'); 60 $this->assert Reference($this->resultSuccess, $result);66 $this->assertSame($this->resultSuccess, $result); 61 67 } 62 68 63 69 /** 64 70 * assure that strategy works as expected 71 * 72 * @test 65 73 */ 66 public function testFailoverWithoutSuccess()74 public function failoverWithoutSuccess() 67 75 { 68 76 $authenticators = array($this->authenticatorFailure, $this->authenticatorInvalid, $this->authenticatorSuccess); 69 $this->authenticatorInvalid->expect Once('authenticate');70 $this->authenticatorSuccess->expect Never('authenticate');77 $this->authenticatorInvalid->expects($this->once())->method('authenticate')->will($this->returnValue($this->resultInvalid)); 78 $this->authenticatorSuccess->expects($this->never())->method('authenticate'); 71 79 $result = $this->strategy->authenticate($authenticators, 'foo'); 72 $this->assert Reference($this->resultInvalid, $result);80 $this->assertSame($this->resultInvalid, $result); 73 81 } 74 82 75 83 /** 76 84 * assure that strategy works as expected 85 * 86 * @test 77 87 */ 78 public function testFailoverOnly()88 public function failoverOnly() 79 89 { 80 90 $authenticators = array($this->authenticatorFailure); 81 91 $result = $this->strategy->authenticate($authenticators, 'foo'); 82 $this->assert Reference($this->resultFailure, $result);92 $this->assertSame($this->resultFailure, $result); 83 93 } 84 94 } trunk/src/test/php/net/stubbles/auth/strategy/stubAuthOrStrategyTestCase.php
r1209 r1235 27 27 /** 28 28 * assure that strategy works as expected 29 * 30 * @test 29 31 */ 30 public function testSuccess()32 public function success() 31 33 { 32 34 $authenticators = array($this->authenticatorSuccess, $this->authenticatorInvalid, $this->authenticatorFailure); 33 $this->authenticatorInvalid->expect Never('authenticate');34 $this->authenticatorFailure->expect Never('authenticate');35 $this->authenticatorInvalid->expects($this->never())->method('authenticate'); 36 $this->authenticatorFailure->expects($this->never())->method('authenticate'); 35 37 $result = $this->strategy->authenticate($authenticators, 'foo'); 36 $this->assert Reference($this->resultSuccess, $result);38 $this->assertSame($this->resultSuccess, $result); 37 39 } 38 40 39 41 /** 40 42 * assure that strategy works as expected 43 * 44 * @test 41 45 */ 42 public function testNoSuccess()46 public function noSuccess() 43 47 { 44 48 $authenticators = array($this->authenticatorInvalid, $this->authenticatorFailure); 45 $this->authenticatorInvalid->expect Once('authenticate');46 $this->authenticatorFailure->expect Once('authenticate');49 $this->authenticatorInvalid->expects($this->once())->method('authenticate')->will($this->returnValue($this->resultInvalid)); 50 $this->authenticatorFailure->expects($this->once())->method('authenticate')->will($this->returnValue($this->resultFailure)); 47 51 $result = $this->strategy->authenticate($authenticators, 'foo'); 48 $this->assert Reference($this->resultFailure, $result);52 $this->assertSame($this->resultFailure, $result); 49 53 } 50 54 } trunk/src/test/php/net/stubbles/auth/strategy/stubAuthStrategyBaseTestCase.php
r1209 r1235 8 8 */ 9 9 stubClassLoader::load('net::stubbles::auth::strategy::stubAuthOrStrategy'); 10 Mock::generate('stubAuthenticator');11 10 /** 12 11 * Base test case for net::stubbles::auth::strategy::stubAuth*Strategy. … … 15 14 * @subpackage auth_strategy_test 16 15 */ 17 abstract class stubAuthStrategyBaseTestCase extends UnitTestCase16 abstract class stubAuthStrategyBaseTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 44 43 * mocked authenticator who succeeds 45 44 * 46 * @var SimpleMock45 * @var PHPUnit_Framework_MockObject_MockObject 47 46 */ 48 47 protected $authenticatorSuccess; … … 50 49 * mocked authenticator who stumbles accross invalid credentials 51 50 * 52 * @var SimpleMock51 * @var PHPUnit_Framework_MockObject_MockObject 53 52 */ 54 53 protected $authenticatorInvalid; … … 56 55 * mocked authenticator who fails 57 56 * 58 * @var SimpleMock57 * @var PHPUnit_Framework_MockObject_MockObject 59 58 */ 60 59 protected $authenticatorFailure; … … 69 68 $this->resultInvalid = new stubAuthResult(stubAuthResult::STATUS_CREDENTIALS_INVALID, 'foo'); 70 69 $this->resultFailure = new stubAuthResult(stubAuthResult::STATUS_AUTHENTICATOR_FAILURE, 'foo'); 71 $this->authenticatorSuccess = new MockstubAuthenticator(); 72 $this->authenticatorSuccess->setReturnValue('authenticate', $this->resultSuccess); 73 $this->authenticatorInvalid = new MockstubAuthenticator(); 74 $this->authenticatorInvalid->setReturnValue('authenticate', $this->resultInvalid); 75 $this->authenticatorFailure = new MockstubAuthenticator(); 76 $this->authenticatorFailure->setReturnValue('authenticate', $this->resultFailure); 70 $this->authenticatorSuccess = $this->getMock('stubAuthenticator'); 71 $this->authenticatorSuccess->expects($this->any()) 72 ->method('authenticate') 73 ->will($this->returnValue($this->resultSuccess)); 74 $this->authenticatorInvalid = $this->getMock('stubAuthenticator'); 75 $this->authenticatorInvalid->expects($this->any()) 76 ->method('authenticate') 77 ->will($this->returnValue($this->resultInvalid)); 78 $this->authenticatorFailure = $this->getMock('stubAuthenticator'); 79 $this->authenticatorFailure->expects($this->any()) 80 ->method('authenticate') 81 ->will($this->returnValue($this->resultFailure)); 77 82 } 78 83 trunk/src/test/php/net/stubbles/auth/stubAuthTestCase.php
r1209 r1235 8 8 */ 9 9 stubClassLoader::load('net::stubbles::auth::stubAuth'); 10 Mock::generate('stubAuthStrategy');11 Mock::generate('stubAuthStorage');12 Mock::generate('stubAuthenticator');13 10 /** 14 11 * Tests for net::stubbles::auth::stubAuth. … … 17 14 * @subpackage auth_test 18 15 */ 19 class stubAuthTestCase extends UnitTestCase16 class stubAuthTestCase extends PHPUnit_Framework_TestCase 20 17 { 21 18 /** … … 28 25 * a mocked strategy 29 26 * 30 * @var SimpleMock27 * @var PHPUnit_Framework_MockObject_MockObject 31 28 */ 32 29 protected $strategy; … … 34 31 * a mocked storage 35 32 * 36 * @var SimpleMock33 * @var PHPUnit_Framework_MockObject_MockObject 37 34 */ 38 35 protected $storage; 39 36 40 37 /** 41 * set up t he test environment38 * set up test environment 42 39 */ 43 public function set up()40 public function setUp() 44 41 { 45 $this->strategy = new MockstubAuthStrategy();46 $this->storage = new MockstubAuthStorage();42 $this->strategy = $this->getMock('stubAuthStrategy'); 43 $this->storage = $this->getMock('stubAuthStorage'); 47 44 $this->auth = stubAuth::createInstance($this->strategy, $this->storage, '__test'); 48 45 } 49 46 50 47 /** 51 * restoreenvironment48 * clean up environment 52 49 */ 53 50 public function tearDown() … … 58 55 /** 59 56 * assure that always the same instance is returned 57 * 58 * @test 60 59 */ 61 public function testReference()60 public function equalInstanceNamesReferSameInstance() 62 61 { 63 62 $auth = stubAuth::getInstance('__test'); 64 $this->assertReference($this->auth, $auth); 65 66 $this->expectException('stubAuthException'); 63 $this->assertSame($this->auth, $auth); 64 $auth = stubAuth::createInstance($this->strategy, $this->storage, '__test'); 65 $this->assertSame($this->auth, $auth); 66 } 67 68 /** 69 * assure that always the same instance is returned 70 * 71 * @test 72 * @expectedException stubAuthException 73 */ 74 public function invalidInstanceNameThrowsAuthException() 75 { 67 76 stubAuth::getInstance('foo'); 68 77 } … … 70 79 /** 71 80 * assure that checking validity of an auth instance works as expected 81 * 82 * @test 72 83 */ 73 public function testValid()84 public function shortcutForValidityCheckCallsStorage() 74 85 { 75 $this->storage->setReturnValueAt(0, 'isValid', true); 76 $this->storage->setReturnValueAt(1, 'isValid', false); 86 $this->storage->expects($this->exactly(2)) 87 ->method('isValid') 88 ->will($this->onConsecutiveCalls(true, false)); 77 89 $this->assertTrue(stubAuth::isValid('__test')); 78 90 $this->assertFalse(stubAuth::isValid('__test')); … … 82 94 /** 83 95 * assure correct storage handling 96 * 97 * @test 84 98 */ 85 public function testStorage()99 public function returnedStorageIsReferenceToGivenStorage() 86 100 { 87 101 $storage = $this->auth->getStorage(); 88 $this->assert Reference($this->storage, $storage);102 $this->assertSame($this->storage, $storage); 89 103 } 90 104 91 105 /** 92 106 * assure that trying to authenticate without authenticators throws an exception 107 * 108 * @test 109 * @expectedException stubAuthException 93 110 */ 94 public function testAuthenticateWithoutAuthenticators()111 public function authenticateWithoutAuthenticatorsThrowsAuthException() 95 112 { 96 $this->expectException('stubAuthException');97 113 $this->auth->authenticate('foo'); 98 114 } … … 100 116 /** 101 117 * assure that trying to authenticate with authenticators works as expexcted 118 * 119 * @test 102 120 */ 103 public function testAuthenticateWithAuthenticators()121 public function authenticateWithAuthenticators() 104 122 { 105 $authenticator = new MockstubAuthenticator();123 $authenticator = $this->getMock('stubAuthenticator'); 106 124 $this->auth->addAuthenticator($authenticator); 107 125 $authResult = new stubAuthResult(stubAuthResult::STATUS_SUCCESS, 'foo'); 108 $this->strategy->expectOnce('authenticate', array(array($authenticator), 'foo')); 109 $this->strategy->setReturnValue('authenticate', $authResult); 110 $this->storage->expectOnce('setResult',array($authResult)); 126 $this->assertEquals('foo', $authResult->getCredentials()); 127 $this->strategy->expects($this->once()) 128 ->method('authenticate') 129 ->with($this->equalTo(array($authenticator)), $this->equalTo('foo')) 130 ->will($this->returnValue($authResult)); 131 $this->storage->expects($this->once()) 132 ->method('setResult') 133 ->with($this->equalTo($authResult)); 111 134 $storage = $this->auth->authenticate('foo'); 112 $this->assert Reference($this->storage, $storage);135 $this->assertSame($this->storage, $storage); 113 136 } 114 137 } trunk/src/test/php/net/stubbles/events/EventTestSuite.php
r768 r1235 13 13 * @subpackage test 14 14 */ 15 class EventTestSuite extends TestSuite15 class EventTestSuite extends PHPUnit_Framework_TestSuite 16 16 { 17 17 /** 18 * constructor 18 * returns the test suite to be run 19 * 20 * @return PHPUnit_Framework_TestSuite 19 21 */ 20 public function __construct()22 public static function suite() 21 23 { 22 $dir = dirname(__FILE__); 23 $this->TestSuite('All events tests'); 24 $this->addTestFile($dir . '/stubCallbackListenerTestCase.php'); 25 $this->addTestFile($dir . '/stubEventTestCase.php'); 26 $this->addTestFile($dir . '/stubLazyEventListenerTestCase.php'); 27 $this->addTestFile($dir . '/stubEventDispatcherTestCase.php'); 28 $this->addTestFile($dir . '/stubNonCancelableEventTestCase.php'); 24 $suite = new self(); 25 $dir = dirname(__FILE__); 26 $suite->addTestFile($dir . '/stubCallbackListenerTestCase.php'); 27 $suite->addTestFile($dir . '/stubEventTestCase.php'); 28 $suite->addTestFile($dir . '/stubLazyEventListenerTestCase.php'); 29 $suite->addTestFile($dir . '/stubEventDispatcherTestCase.php'); 30 $suite->addTestFile($dir . '/stubNonCancelableEventTestCase.php'); 31 return $suite; 29 32 } 30 33 } trunk/src/test/php/net/stubbles/events/stubCallbackListenerTestCase.php
r1209 r1235 15 15 * @subpackage events_test 16 16 */ 17 class stubCallbackListenerTestCase extends UnitTestCase17 class stubCallbackListenerTestCase extends PHPUnit_Framework_TestCase 18 18 { 19 19 /** 20 20 * assure that a lazy initialization with the callback listener works correct 21 */ 22 public function testLazyInitialization() 21 * 22 * @test 23 */ 24 public function lazyInitialization() 23 25 { 24 26 $callbacklistener = new stubCallbackListener('TestStubCallback', 'doSomething'); … … 26 28 $this->assertFalse($callbacklistener->isNotified()); 27 29 $this->assertFalse($callbacklistener->autoremove()); 30 $this->assertEquals('TestStubCallback', $callbacklistener->getCallbackClassName()); 31 $this->assertEquals('doSomething', $callbacklistener->getCallbackMethodName()); 28 32 $event = new stubEvent('eventName'); 29 33 $callbacklistener->handleEvent($event); 30 34 $testEvent = $callbacklistener->getEvent(); 31 $this->assert Reference($event, $testEvent);35 $this->assertSame($event, $testEvent); 32 36 $instance = $callbacklistener->getInstance(); 33 $this->assert IsA($instance, 'TestStubCallback');34 $this->assertEqual ($instance->getInvocations(), 1);37 $this->assertType('TestStubCallback', $instance); 38 $this->assertEquals(1, $instance->getInvocations()); 35 39 $this->assertTrue($callbacklistener->isNotified()); 36 40 } … … 38 42 /** 39 43 * assure that a normal initialization with the callback listener works correct 40 */ 41 public function testNonLazyInitialization() 44 * 45 * @test 46 */ 47 public function nonLazyInitialization() 42 48 { 43 49 $callback = new TestStubCallback(); … … 46 52 $this->assertFalse($callbacklistener->isNotified()); 47 53 $this->assertTrue($callbacklistener->autoremove()); 54 $this->assertEquals('TestStubCallback', $callbacklistener->getCallbackClassName()); 55 $this->assertEquals('doSomething', $callbacklistener->getCallbackMethodName()); 48 56 $event = new stubEvent('eventName'); 49 57 $callbacklistener->handleEvent($event); 50 58 $testEvent = $callbacklistener->getEvent(); 51 $this->assert Reference($event, $testEvent);59 $this->assertSame($event, $testEvent); 52 60 $instance = $callbacklistener->getInstance(); 53 $this->assert Reference($instance, $callback);54 $this->assertEqual ($instance->getInvocations(), 1);61 $this->assertSame($instance, $callback); 62 $this->assertEquals(1, $instance->getInvocations()); 55 63 $this->assertTrue($callbacklistener->isNotified()); 56 64 } … … 58 66 /** 59 67 * assure that a static callback works correct 60 */ 61 public function testStaticCallback() 68 * 69 * @test 70 */ 71 public function staticCallback() 62 72 { 63 73 $callbacklistener = new stubCallbackListener('TestStubCallback', 'doSomethingStatic', false); … … 68 78 $callbacklistener->handleEvent($event); 69 79 $testEvent = $callbacklistener->getEvent(); 70 $this->assert Reference($event, $testEvent);80 $this->assertSame($event, $testEvent); 71 81 $instance = $callbacklistener->getInstance(); 72 82 $this->assertNull($instance); 73 $this->assertEqual (TestStubCallback::$staticInvocations, 1);83 $this->assertEquals(1, TestStubCallback::$staticInvocations); 74 84 $this->assertTrue($callbacklistener->isNotified()); 75 85 } … … 77 87 /** 78 88 * assure that calling a non-public callback throws a stubCallbackException 79 */ 80 public function testNonPublicCallback() 89 * 90 * @test 91 * @expectedException stubCallbackException 92 */ 93 public function nonPublicCallback() 81 94 { 82 95 $callbacklistener = new stubCallbackListener('TestStubCallback', 'forceException'); 83 96 $event = new stubEvent('eventName'); 84 $this->expectException('stubCallbackException');85 97 $callbacklistener->handleEvent($event); 86 98 } … … 88 100 /** 89 101 * assure that calling a non-existing callback method throws a stubCallbackException 90 */ 91 public function testNonExistingCallbackMethod() 102 * 103 * @test 104 * @expectedException stubCallbackException 105 */ 106 public function nonExistingCallbackMethod() 92 107 { 93 108 $callbacklistener = new stubCallbackListener('TestStubCallback', 'notExisting'); 94 109 $event = new stubEvent('eventName'); 95 $this->expectException('stubCallbackException');96 110 $callbacklistener->handleEvent($event); 97 111 } … … 99 113 /** 100 114 * assure that calling a non-existing callback class throws a stubCallbackException 101 */ 102 public function testNonExistingCallbackClass() 115 * 116 * @test 117 * @expectedException stubClassNotFoundException 118 */ 119 public function nonExistingCallbackClass() 103 120 { 104 121 $callbacklistener = new stubCallbackListener('NotExisting', 'notExisting'); 105 122 $event = new stubEvent('eventName'); 106 $this->expectException('stubClassNotFoundException');107 123 $callbacklistener->handleEvent($event); 108 124 } … … 110 126 /** 111 127 * assure that a failed instantiation of the callback class throws a stubCallbackException 112 */ 113 public function testFailingInvocationWrongMethod() 128 * 129 * @test 130 * @expectedException stubCallbackException 131 */ 132 public function failingInvocationWrongMethod() 114 133 { 115 134 $callbacklistener = new stubCallbackListener('TestStubCallback2', 'notExisting'); 116 135 $event = new stubEvent('eventName'); 117 $this->expectException('stubCallbackException');118 136 $callbacklistener->handleEvent($event); 119 137 } … … 121 139 /** 122 140 * assure that a failed invocation of the callback method throws a stubCallbackException 123 */ 124 public function testFailingInvocation() 141 * 142 * @test 143 * @expectedException stubCallbackException 144 */ 145 public function failingInvocation() 125 146 { 126 147 $callbacklistener = new stubCallbackListener('TestStubCallback', 'failsInvocation'); 127 148 $event = new stubEvent('eventName'); 128 $this->expectException('stubCallbackException');129 149 $callbacklistener->handleEvent($event); 130 150 } … … 132 152 /** 133 153 * assure that creating a stubCallbackListener with an illegal argument throws a stubCallbackException 134 */ 135 public function testIllegalConstructorArgumentInstance() 136 { 137 $this->expectException('stubIllegalArgumentException'); 154 * 155 * @test 156 * @expectedException stubIllegalArgumentException 157 */ 158 public function illegalConstructorArgumentInstance() 159 { 138 160 $callbacklistener = new stubCallbackListener(6100, 'pimp'); 139 161 } … … 141 163 /** 142 164 * assure that creating a stubCallbackListener with an illegal argument throws a stubCallbackException 143 */ 144 public function testIllegalConstructorArgumentMethod() 145 { 146 $this->expectException('stubIllegalArgumentException'); 165 * 166 * @test 167 * @expectedException stubIlleg
