Changeset 1250

Show
Ignore:
Timestamp:
01/17/08 00:47:31 (9 months ago)
Author:
mikey
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/stubFrontController.php

    r1242 r1250  
    1616                      'net::stubbles::websites::cache::stubWebsiteCacheFactory', 
    1717                      'net::stubbles::websites::processors::stubProcessorResolverFactory' 
    18                        
    1918); 
    2019/** 
  • trunk/src/test/AllTests.php

    r1236 r1250  
    2626require_once $dir . '/php/net/stubbles/events/EventTestSuite.php'; 
    2727require_once $dir . '/php/net/stubbles/ioc/IOCTestSuite.php'; 
     28require_once $dir . '/php/net/stubbles/websites/WebsitesTestSuite.php'; 
    2829/** 
    2930 * Class to organize all tests. 
     
    5455        $suite->addTestSuite('EventTestSuite'); 
    5556        $suite->addTestSuite('IOCTestSuite'); 
     57        $suite->addTestSuite('WebsitesTestSuite'); 
    5658        return $suite; 
    5759    } 
  • trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php

    r1136 r1250  
    1313 * @subpackage  test 
    1414 */ 
    15 class WebsitesTestSuite extends TestSuite 
     15class WebsitesTestSuite extends PHPUnit_Framework_TestSuite 
    1616{ 
    1717    /** 
    18      * constructor 
     18     * returns the test suite to be run 
     19     * 
     20     * @return  PHPUnit_Framework_TestSuite 
    1921     */ 
    20     public function __construct() 
     22    public static function suite() 
    2123    { 
     24        $suite = new self(); 
    2225        $dir = dirname(__FILE__); 
    23         $this->TestSuite('All websites classes tests'); 
    24         $this->addTestFile($dir . '/stubFrontControllerProcessTestCase.php'); 
    25         $this->addTestFile($dir . '/stubPageTestCase.php'); 
     26        $suite->addTestFile($dir . '/stubFrontControllerTestCase.php'); 
     27        $suite->addTestFile($dir . '/stubPageTestCase.php'); 
    2628         
    2729        // cache tests 
    28         $this->addTestFile($dir . '/cache/stubAbstractWebsiteCacheTestCase.php'); 
    29         $this->addTestFile($dir . '/cache/stubDefaultWebsiteCacheFactoryTestCase.php'); 
    30         $this->addTestFile($dir . '/cache/stubDefaultWebsiteCacheTestCase.php'); 
    31         $this->addTestFile($dir . '/cache/stubGzipWebsiteCacheTestCase.php'); 
     30        /*$suite->addTestFile($dir . '/cache/stubAbstractWebsiteCacheTestCase.php'); 
     31        $suite->addTestFile($dir . '/cache/stubDefaultWebsiteCacheFactoryTestCase.php'); 
     32        $suite->addTestFile($dir . '/cache/stubDefaultWebsiteCacheTestCase.php'); 
     33        $suite->addTestFile($dir . '/cache/stubGzipWebsiteCacheTestCase.php');*/ 
    3234 
    3335        // memphis tests 
    34         $this->addTestFile($dir . '/memphis/stubMemphisIncludeFilePageElementTestCase.php'); 
    35         $this->addTestFile($dir . '/memphis/stubMemphisPageElementTestCase.php'); 
    36         $this->addTestFile($dir . '/memphis/stubMemphisProcessorTestCase.php'); 
     36        /*$suite->addTestFile($dir . '/memphis/stubMemphisIncludeFilePageElementTestCase.php'); 
     37        $suite->addTestFile($dir . '/memphis/stubMemphisPageElementTestCase.php'); 
     38        $suite->addTestFile($dir . '/memphis/stubMemphisProcessorTestCase.php');*/ 
    3739 
    3840        // processors tests 
    39         $this->addTestFile($dir . '/processors/stubAbstractProcessorResolverTestCase.php'); 
    40         $this->addTestFile($dir . '/processors/stubDefaultProcessorResolverTestCase.php'); 
    41         $this->addTestFile($dir . '/processors/stubProcessorResolverXJConfFactoryTestCase.php'); 
    42         $this->addTestFile($dir . '/processors/stubSimpleProcessorResolverTestCase.php'); 
     41        /*$suite->addTestFile($dir . '/processors/stubAbstractProcessorResolverTestCase.php'); 
     42        $suite->addTestFile($dir . '/processors/stubDefaultProcessorResolverTestCase.php'); 
     43        $suite->addTestFile($dir . '/processors/stubProcessorResolverXJConfFactoryTestCase.php'); 
     44        $suite->addTestFile($dir . '/processors/stubSimpleProcessorResolverTestCase.php');*/ 
    4345 
    4446        // xml tests 
    45         $this->addTestFile($dir . '/xml/stubShowLastXMLInterceptorTestCase.php'); 
    46         $this->addTestFile($dir . '/xml/stubXMLPostInterceptorTestCase.php'); 
    47         $this->addTestFile($dir . '/xml/stubXMLProcessorTestCase.php'); 
    48         $this->addTestFile($dir . '/xml/stubXMLResponseTestCase.php'); 
     47        /*$suite->addTestFile($dir . '/xml/stubShowLastXMLInterceptorTestCase.php'); 
     48        $suite->addTestFile($dir . '/xml/stubXMLPostInterceptorTestCase.php'); 
     49        $suite->addTestFile($dir . '/xml/stubXMLProcessorTestCase.php'); 
     50        $suite->addTestFile($dir . '/xml/stubXMLResponseTestCase.php');*/ 
     51        return $suite; 
    4952    } 
    5053} 
  • trunk/src/test/php/net/stubbles/websites/stubFrontControllerTestCase.php

    r1231 r1250  
    88 */ 
    99stubClassLoader::load('net::stubbles::websites::stubFrontController'); 
    10 Mock::generate('stubRequest'); 
    11 Mock::generate('stubSession'); 
    12 Mock::generate('stubResponse'); 
    13 Mock::generate('stubPostInterceptor'); 
    14 Mock::generate('stubPreInterceptor'); 
    15 Mock::generate('stubProcessor'); 
    16 Mock::generate('stubProcessorResolver'); 
    17 Mock::generate('stubInterceptorInitializer'); 
    18 Mock::generate('stubProcessorResolverFactory'); 
    19 Mock::generate('stubRegistryInitializer'); 
    20 Mock::generate('stubWebsiteCacheFactory'); 
    21 require_once dirname(__FILE__) . '/TeststubFrontController.php'; 
     10/** 
     11 * Class that extends the front controller to make it testable. 
     12 * 
     13 * @package     stubbles 
     14 * @subpackage  websites_test 
     15 */ 
     16class TeststubFrontController extends stubFrontController 
     17
     18    /** 
     19     * returns the created request instance 
     20     * 
     21     * @return  stubRequest 
     22     */ 
     23    public function getRequest() 
     24    { 
     25        return $this->request; 
     26    } 
     27 
     28    /** 
     29     * returns the created session instance 
     30     * 
     31     * @return  stubSession 
     32     */ 
     33    public function getSession() 
     34    { 
     35        return $this->session; 
     36    } 
     37 
     38    /** 
     39     * sets the response instance 
     40     * 
     41     * @return  stubResponse 
     42     */ 
     43    public function setResponse(stubResponse $response) 
     44    { 
     45        $this->response = $response; 
     46    } 
     47
    2248/** 
    2349 * Tests for net::stubbles::websites::stubFrontController. 
     
    2652 * @subpackage  websites_test 
    2753 */ 
    28 class stubFrontControllerProcessTestCase extends UnitTestCase 
     54class stubFrontControllerProcessTestCase extends PHPUnit_Framework_TestCase 
    2955{ 
    3056    /** 
     
    3763     * mocked interceptor initializer 
    3864     * 
    39      * @var  SimpleMock 
     65     * @var  PHPUnit_Framework_MockObject_MockObject 
    4066     */ 
    4167    protected $mockInterceptorInitializer; 
     
    4369     * access to request 
    4470     * 
    45      * @var  SimpleMock 
     71     * @var  PHPUnit_Framework_MockObject_MockObject 
    4672     */ 
    4773    protected $mockRequest; 
     
    4975     * access to session 
    5076     * 
    51      * @var  SimpleMock 
     77     * @var  PHPUnit_Framework_MockObject_MockObject 
    5278     */ 
    5379    protected $mockSession; 
     
    5581     * access to response 
    5682     * 
    57      * @var  SimpleMock 
     83     * @var  PHPUnit_Framework_MockObject_MockObject 
    5884     */ 
    5985    protected $mockResponse; 
     
    6187     * access to response 
    6288     * 
    63      * @var  SimpleMock 
     89     * @var  PHPUnit_Framework_MockObject_MockObject 
    6490     */ 
    6591    protected $mockResponse2; 
     
    6793     * the mocked resolver 
    6894     * 
    69      * @var  SimpleMock 
     95     * @var  PHPUnit_Framework_MockObject_MockObject 
    7096     */ 
    7197    protected $mockProcessorResolver; 
     
    7399     * the mocked processor 
    74100     * 
    75      * @var  SimpleMock 
     101     * @var  PHPUnit_Framework_MockObject_MockObject 
    76102     */ 
    77103    protected $mockProcessor; 
     
    79105     * mocked website cache factory 
    80106     * 
    81      * @var  stubWebsiteCacheFactory 
     107     * @var  PHPUnit_Framework_MockObject_MockObject 
    82108     */ 
    83109    protected $mockWebsiteCacheFactory; 
     
    88114    public function setUp() 
    89115    { 
    90         $mockProcessorResolverFactory = new MockstubProcessorResolverFactory(); 
    91         $this->mockProcessorResolver  = new MockstubProcessorResolver(); 
    92         $mockProcessorResolverFactory->setReturnValue('getResolver', $this->mockProcessorResolver); 
    93         $this->mockInterceptorInitializer = new MockstubInterceptorInitializer(); 
    94         $this->frontController = new TeststubFrontController(new MockstubRegistryInitializer(), $this->mockInterceptorInitializer, $mockProcessorResolverFactory); 
    95         $this->mockRequest     = new MockstubRequest(); 
    96         $this->frontController->setRequest($this->mockRequest); 
    97         $this->mockSession     = new MockstubSession(); 
    98         $this->frontController->setSession($this->mockSession); 
    99         $this->mockResponse    = new MockstubResponse(); 
     116        $mockProcessorResolverFactory = $this->getMock('stubProcessorResolverFactory'); 
     117        $this->mockProcessorResolver  = $this->getMock('stubProcessorResolver'); 
     118        $this->mockProcessor          = $this->getMock('stubProcessor'); 
     119        $mockProcessorResolverFactory->expects($this->once()) 
     120                                     ->method('getResolver') 
     121                                     ->will($this->returnValue($this->mockProcessorResolver)); 
     122        $this->mockProcessorResolver->expects($this->once()) 
     123                                    ->method('resolve') 
     124                                    ->will($this->returnValue($this->mockProcessor)); 
     125        $this->mockInterceptorInitializer = $this->getMock('stubInterceptorInitializer'); 
     126        stubRegistry::setConfig(stubRequest::CLASS_REGISTRY_KEY, get_class($this->getMock('stubRequest'))); 
     127        stubRegistry::setConfig(stubSession::CLASS_REGISTRY_KEY, get_class($this->getMock('stubSession'))); 
     128        $this->frontController = new TeststubFrontController($this->getMock('stubRegistryInitializer'), $this->mockInterceptorInitializer, $mockProcessorResolverFactory); 
     129         
     130        $this->mockRequest  = $this->frontController->getRequest(); 
     131        $this->mockSession  = $this->frontController->getSession(); 
     132        $this->mockResponse = $this->getMock('stubResponse'); 
    100133        $this->frontController->setResponse($this->mockResponse); 
    101         $this->mockProcessor   = new MockstubProcessor(); 
    102         $this->mockProcessorResolver->setReturnValue('resolve', $this->mockProcessor); 
    103         $this->mockProcessor->setReturnValue('process', $this->mockProcessor); 
    104         $this->mockResponse2   = new MockstubResponse(); 
    105         $this->mockProcessor->setReturnValue('getResponse', $this->mockResponse2); 
    106         $this->mockWebsiteCacheFactory = new MockstubWebsiteCacheFactory(); 
    107     } 
    108  
    109     /** 
    110      * assure that processing ends when request is cancelled 
    111      */ 
    112     public function testProcessWithPreInterceptorCancellingRequest() 
    113     { 
    114         $preInterceptor1 = new MockstubPreInterceptor(); 
    115         $preInterceptor1->expectOnce('preProcess'); 
    116         $preInterceptor2 = new MockstubPreInterceptor(); 
    117         $preInterceptor2->expectNever('preProcess'); 
    118         $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array($preInterceptor1, $preInterceptor2)); 
    119         $this->mockInterceptorInitializer->expectNever('getPostInterceptors'); 
    120         $this->mockRequest->expectOnce('isCancelled'); 
    121         $this->mockRequest->setReturnValue('isCancelled', true); 
    122         $this->mockResponse->expectOnce('send'); 
    123         $this->mockProcessorResolver->expectOnce('resolve'); 
    124         $this->mockProcessor->expectOnce('getInterceptorDescriptor'); 
    125         $this->mockProcessor->setReturnValue('getInterceptorDescriptor', 'interceptors'); 
    126         $this->mockProcessor->expectNever('process'); 
    127         $this->mockWebsiteCacheFactory->expectNever('configure'); 
     134         
     135        $this->mockWebsiteCacheFactory = $this->getMock('stubWebsiteCacheFactory'); 
     136    } 
     137 
     138    /** 
     139     * assure that processing ends when request is cancelled 
     140     * 
     141     * @test 
     142     */ 
     143    public function processWithPreInterceptorCancellingRequest() 
     144    { 
     145        $preInterceptor1 = $this->getMock('stubPreInterceptor'); 
     146        $preInterceptor1->expects($this->once())->method('preProcess'); 
     147        $preInterceptor2 = $this->getMock('stubPreInterceptor'); 
     148        $preInterceptor2->expects($this->never())->method('preProcess'); 
     149        $this->mockInterceptorInitializer->expects($this->once()) 
     150                                         ->method('getPreInterceptors') 
     151                                         ->will($this->returnValue(array($preInterceptor1, $preInterceptor2))); 
     152        $this->mockInterceptorInitializer->expects($this->never())->method('getPostInterceptors'); 
     153        $this->mockRequest->expects($this->once())->method('isCancelled')->will($this->returnValue(true)); 
     154        $this->mockResponse->expects($this->once())->method('send'); 
     155        $this->mockProcessor->expects($this->once()) 
     156                            ->method('getInterceptorDescriptor') 
     157                            ->will($this->returnValue('interceptors')); 
     158        $this->mockProcessor->expects($this->never())->method('process'); 
     159        $this->mockWebsiteCacheFactory->expects($this->never())->method('configure'); 
    128160        $this->frontController->setWebsiteCacheFactory($this->mockWebsiteCacheFactory); 
    129161        $this->frontController->process(); 
     
    132164    /** 
    133165     * assure that processing ends when request is cancelled 
    134      */ 
    135     public function testProcessWithProcessorCancellingRequest() 
    136     { 
    137         $postInterceptor1 = new MockstubPostInterceptor(); 
    138         $postInterceptor1->expectNever('postProcess'); 
    139         $postInterceptor2 = new MockstubPostInterceptor(); 
    140         $postInterceptor2->expectNever('postProcess'); 
    141         $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array()); 
    142         $this->mockInterceptorInitializer->setReturnValue('getPostInterceptors', array($postInterceptor1, $postInterceptor2)); 
    143         $this->mockRequest->expectOnce('isCancelled'); 
    144         $this->mockRequest->setReturnValue('isCancelled', true); 
    145         $this->mockResponse2->expectOnce('send'); 
    146         $this->mockProcessorResolver->expectOnce('resolve'); 
    147         $this->frontController->process(); 
    148     } 
    149  
    150     /** 
    151      * assure that processing ends when request is cancelled 
    152      */ 
    153     public function testProcessWithPostInterceptorCancellingRequest() 
    154     { 
    155         $postInterceptor1 = new MockstubPostInterceptor(); 
    156         $postInterceptor1->expectOnce('postProcess'); 
    157         $postInterceptor2 = new MockstubPostInterceptor(); 
    158         $postInterceptor2->expectNever('postProcess'); 
    159         $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array()); 
    160         $this->mockInterceptorInitializer->setReturnValue('getPostInterceptors', array($postInterceptor1, $postInterceptor2)); 
    161         $this->mockRequest->expectCallcount('isCancelled', 2); 
    162         $this->mockRequest->setReturnValueAt(0, 'isCancelled', false); 
    163         $this->mockRequest->setReturnValueAt(1, 'isCancelled', true); 
    164         $this->mockResponse2->expectOnce('send'); 
    165         $this->mockProcessorResolver->expectOnce('resolve'); 
    166         $this->frontController->process(); 
    167     } 
    168  
    169     /** 
    170      * assure that processing ends when request is cancelled 
    171      */ 
    172     public function testProcessWithoutCancellingRequest() 
    173     { 
    174         $preInterceptor1 = new MockstubPreInterceptor(); 
    175         $preInterceptor1->expectOnce('preProcess'); 
    176         $preInterceptor2 = new MockstubPreInterceptor(); 
    177         $preInterceptor2->expectOnce('preProcess'); 
    178         $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array($preInterceptor1, $preInterceptor2)); 
    179         $postInterceptor1 = new MockstubPostInterceptor(); 
    180         $postInterceptor1->expectOnce('postProcess'); 
    181         $postInterceptor2 = new MockstubPostInterceptor(); 
    182         $postInterceptor2->expectOnce('postProcess'); 
    183         $this->mockInterceptorInitializer->setReturnValue('getPostInterceptors', array($postInterceptor1, $postInterceptor2)); 
    184         $this->mockRequest->setReturnValue('isCancelled', false); 
    185         $this->mockResponse2->expectOnce('send'); 
    186         $this->mockProcessorResolver->expectOnce('resolve'); 
    187         $this->mockWebsiteCacheFactory->expectOnce('configure'); 
     166     * 
     167     * @test 
     168     */ 
     169    public function processWithProcessorCancellingRequest() 
     170    { 
     171        $postInterceptor1 = $this->getMock('stubPostInterceptor'); 
     172        $postInterceptor1->expects($this->never())->method('postProcess'); 
     173        $postInterceptor2 = $this->getMock('stubPostInterceptor'); 
     174        $postInterceptor2->expects($this->never())->method('postProcess'); 
     175        $this->mockInterceptorInitializer->expects($this->once()) 
     176                                         ->method('getPreInterceptors') 
     177                                         ->will($this->returnValue(array())); 
     178        $this->mockInterceptorInitializer->expects($this->never()) 
     179                                         ->method('getPostInterceptors'); 
     180        $this->mockRequest->expects($this->once())->method('isCancelled')->will($this->returnValue(true)); 
     181        $this->mockProcessor->expects($this->any()) 
     182                            ->method('process') 
     183                            ->will($this->returnValue($this->mockProcessor)); 
     184        $this->mockResponse2 = $this->getMock('stubResponse'); 
     185        $this->mockResponse2->expects($this->once())->method('send'); 
     186        $this->mockProcessor->expects($this->once()) 
     187                            ->method('getResponse') 
     188                            ->will($this->returnValue($this->mockResponse2)); 
     189        $this->frontController->process(); 
     190    } 
     191 
     192    /** 
     193     * assure that processing ends when request is cancelled 
     194     * 
     195     * @test 
     196     */ 
     197    public function processWithPostInterceptorCancellingRequest() 
     198    { 
     199        $postInterceptor1 = $this->getMock('stubPostInterceptor'); 
     200        $postInterceptor1->expects($this->once())->method('postProcess'); 
     201        $postInterceptor2 = $this->getMock('stubPostInterceptor'); 
     202        $postInterceptor2->expects($this->never())->method('postProcess'); 
     203        $this->mockInterceptorInitializer->expects($this->once()) 
     204                                         ->method('getPreInterceptors') 
     205                                         ->will($this->returnValue(array())); 
     206        $this->mockInterceptorInitializer->expects($this->once()) 
     207                                         ->method('getPostInterceptors') 
     208                                         ->will($this->returnValue(array($postInterceptor1, $postInterceptor2))); 
     209        $this->mockRequest->expects($this->exactly(2)) 
     210                          ->method('isCancelled') 
     211                          ->will($this->onConsecutiveCalls(false, true)); 
     212        $this->mockProcessor->expects($this->any()) 
     213                            ->method('process') 
     214                            ->will($this->returnValue($this->mockProcessor)); 
     215        $this->mockResponse2 = $this->getMock('stubResponse'); 
     216        $this->mockResponse2->expects($this->once())->method('send'); 
     217        $this->mockProcessor->expects($this->once()) 
     218                            ->method('getResponse') 
     219                            ->will($this->returnValue($this->mockResponse2)); 
     220        $this->frontController->process(); 
     221    } 
     222 
     223    /** 
     224     * assure that processing ends when request is cancelled 
     225     * 
     226     * @test 
     227     */ 
     228    public function processWithoutCancellingRequest() 
     229    { 
     230        $preInterceptor1 = $this->getMock('stubPreInterceptor'); 
     231        $preInterceptor1->expects($this->once())->method('preProcess'); 
     232        $preInterceptor2 = $this->getMock('stubPreInterceptor'); 
     233        $preInterceptor2->expects($this->once())->method('preProcess'); 
     234        $this->mockInterceptorInitializer->expects($this->once()) 
     235                                         ->method('getPreInterceptors') 
     236                                         ->will($this->returnValue(array($preInterceptor1, $preInterceptor2))); 
     237        $postInterceptor1 = $this->getMock('stubPostInterceptor'); 
     238        $postInterceptor1->expects($this->once())->method('postProcess'); 
     239        $postInterceptor2 = $this->getMock('stubPostInterceptor'); 
     240        $postInterceptor2->expects($this->once())->method('postProcess'); 
     241        $this->mockInterceptorInitializer->expects($this->once()) 
     242                                         ->method('getPostInterceptors') 
     243                                         ->will($this->returnValue(array($postInterceptor1, $postInterceptor2))); 
     244        $this->mockRequest->expects($this->any())->method('isCancelled')->will($this->returnValue(false)); 
     245        $this->mockProcessor->expects($this->any()) 
     246                            ->method('process') 
     247                            ->will($this->returnValue($this->mockProcessor)); 
     248        $this->mockResponse2 = $this->getMock('stubResponse'); 
     249        $this->mockResponse2->expects($this->once())->method('send'); 
     250        $this->mockProcessor->expects($this->once()) 
     251                            ->method('getResponse') 
     252                            ->will($this->returnValue($this->mockResponse2)); 
     253        $this->mockWebsiteCacheFactory->expects($this->once())->method('configure'); 
    188254        $this->frontController->setWebsiteCacheFactory($this->mockWebsiteCacheFactory); 
    189255        $this->frontController->process(); 
  • trunk/src/test/php/net/stubbles/websites/stubPageTestCase.php

    r1231 r1250  
    88 */ 
    99stubClassLoader::load('net::stubbles::websites::stubPage'); 
    10 Mock::generate('stubPageElement'); 
    1110/** 
    1211 * Tests for net::stubbles::websites::stubPage 
     
    1514 * @subpackage  websites_test 
    1615 */ 
    17 class stubPageTestCase extends UnitTestCase 
     16class stubPageTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    2322     */ 
    2423    protected $stubPage; 
    25      
     24 
    2625    /** 
    2726     * set up test environment 
     
    3130        $this->stubPage = new stubPage(); 
    3231    } 
    33      
     32 
    3433    /** 
    3534     * assure that properties are set and retrieved correct 
     35     * 
     36     * @test 
    3637     */ 
    37     public function testProperties() 
     38    public function properties() 
    3839    { 
    3940        $this->assertFalse($this->stubPage->hasProperty('foo')); 
     
    4142        $this->stubPage->setProperty('foo', 'bar'); 
    4243        $this->assertTrue($this->stubPage->hasProperty('foo')); 
    43         $this->assertEqual($this->stubPage->getProperty('foo'), 'bar'); 
     44        $this->assertEquals('bar', $this->stubPage->getProperty('foo')); 
    4445         
    4546        $this->stubPage->setProperties(array('baz' => 'baz', 'bar' => 'foo')); 
     
    4748        $this->assertNull($this->stubPage->getProperty('foo')); 
    4849        $this->assertTrue($this->stubPage->hasProperty('baz')); 
    49         $this->assertEqual($this->stubPage->getProperty('baz'), 'baz'); 
     50        $this->assertEquals('baz', $this->stubPage->getProperty('baz')); 
    5051        $this->assertTrue($this->stubPage->hasProperty('bar')); 
    51         $this->assertEqual($this->stubPage->getProperty('bar'), 'foo'); 
     52        $this->assertEquals('foo', $this->stubPage->getProperty('bar')); 
    5253    } 
    53      
     54 
    5455    /** 
    5556     * assure that page elements are set and retrieved correct 
     57     * 
     58     * @test 
    5659     */ 
    57     public function testPageElements() 
     60    public function pageElementsHandling() 
    5861    { 
    59         $this->assertEqual($this->stubPage->getElements(), array()); 
    60         $mockPageElement1 = new MockstubPageElement(); 
    61         $mockPageElement1->setReturnValue('getName', 'foo'); 
     62        $this->assertEquals(array(), $this->stubPage->getElements()); 
     63        $mockPageElement1 = $this->getMock('stubPageElement'); 
     64        $mockPageElement1->expects($this->any()) 
     65                         ->method('getName') 
     66                         ->will($this->returnValue('foo')); 
    6267        $this->stubPage->addElement($mockPageElement1); 
    63         $mockPageElement2 = new MockstubPageElement(); 
    64         $mockPageElement2->setReturnValue('getName', 'bar'); 
     68        $mockPageElement2 = $this->getMock('stubPageElement'); 
     69        $mockPageElement2->expects($this->any()) 
     70                         ->method('getName') 
     71                         ->will($this->returnValue('bar')); 
    6572        $this->stubPage->addElement($mockPageElement2); 
    66         $this->assertEqual($this->stubPage->getElements(), array('foo' => $mockPageElement1, 
    67                                                                  'bar' => $mockPageElement2 
    68                                                            ) 
     73        $this->assertEquals(array('foo' => $mockPageElement1, 
     74                                  'bar' => $mockPageElement2 
     75                            ), 
     76                            $this->stubPage->getElements() 
    6977        ); 
    7078         
    71         $mockPageElement3 = new MockstubPageElement(); 
    72         $mockPageElement3->setReturnValue('getName', 'foo'); 
     79        $mockPageElement3 = $this->getMock('stubPageElement'); 
     80        $mockPageElement3->expects($this->any()) 
     81                         ->method('getName') 
     82                         ->will($this->returnValue('foo')); 
    7383        $this->stubPage->addElement($mockPageElement3); 
    74         $this->assertEqual($this->stubPage->getElements(), array('foo' => $mockPageElement3, 
    75                                                                  'bar' => $mockPageElement2 
    76                                                            ) 
     84        $this->assertEquals(array('foo' => $mockPageElement3, 
     85                                  'bar' => $mockPageElement2 
     86                            ), 
     87                            $this->stubPage->getElements() 
    7788        ); 
    7889    } 
  • trunk/src/test/run.php

    r1235 r1250  
    3636        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/service/ServiceTestSuite.php'); 
    3737        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/util/UtilTestSuite.php'); 
    38         $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/websites/WebsitesTestSuite.php'); 
    3938        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/websites/variantmanager/VariantManagerTestSuite.php'); 
    4039        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/xml/XMLTestSuite.php');