Changeset 1262
- Timestamp:
- 01/18/08 17:38:43 (10 months ago)
- Files:
-
- trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisIncludeFilePageElementTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisPageElementTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php
r1256 r1262 7 7 * @subpackage test 8 8 */ 9 if (defined('TEST_SRC_PATH') === false) { 10 define('TEST_SRC_PATH', dirname(__FILE__) . '/../../../../'); 11 } 9 12 /** 10 13 * Test suite for all websites classes. … … 34 37 35 38 // memphis tests 36 /*$suite->addTestFile($dir . '/memphis/stubMemphisIncludeFilePageElementTestCase.php');39 $suite->addTestFile($dir . '/memphis/stubMemphisIncludeFilePageElementTestCase.php'); 37 40 $suite->addTestFile($dir . '/memphis/stubMemphisPageElementTestCase.php'); 38 $suite->addTestFile($dir . '/memphis/stubMemphisProcessorTestCase.php'); */41 $suite->addTestFile($dir . '/memphis/stubMemphisProcessorTestCase.php'); 39 42 40 43 // processors tests trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisIncludeFilePageElementTestCase.php
r1231 r1262 14 14 * @subpackage websites_memphis_test 15 15 */ 16 class stubMemphisIncludeFilePageElementTestCase extends UnitTestCase16 class stubMemphisIncludeFilePageElementTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * assure that setting and getting the name of the element works as expected 35 * 36 * @test 35 37 */ 36 public function testName()38 public function name() 37 39 { 38 $this->assertEqual ($this->includeFilePageElement->getName(), '');40 $this->assertEquals('', $this->includeFilePageElement->getName()); 39 41 $this->includeFilePageElement->setName('foo'); 40 $this->assertEqual ($this->includeFilePageElement->getName(), 'foo');42 $this->assertEquals('foo', $this->includeFilePageElement->getName()); 41 43 } 42 44 43 45 /** 44 46 * assure that setting and getting the source of the element works as expected 47 * 48 * @test 45 49 */ 46 public function testSource()50 public function source() 47 51 { 48 $this->assertEqual ($this->includeFilePageElement->getSource(), '');52 $this->assertEquals('', $this->includeFilePageElement->getSource()); 49 53 $this->includeFilePageElement->setSource(TEST_SRC_PATH . '/resources/contentFile.txt'); 50 $this->assertEqual($this->includeFilePageElement->getSource(), TEST_SRC_PATH . '/resources/contentFile.txt'); 51 $this->expectException('stubFileNotFoundException'); 54 $this->assertEquals(TEST_SRC_PATH . '/resources/contentFile.txt', $this->includeFilePageElement->getSource()); 55 } 56 57 /** 58 * assure that setting and getting the source of the element works as expected 59 * 60 * @test 61 * @expectedException stubFileNotFoundException 62 */ 63 public function setSourceToNonExistingFileThrowsFileNotFoundException() 64 { 52 65 $this->includeFilePageElement->setSource(TEST_SRC_PATH . '/resources/doesNotExist'); 53 66 } … … 55 68 /** 56 69 * assure that processing works as expected 70 * 71 * @test 57 72 */ 58 public function testProcess()73 public function process() 59 74 { 60 75 $this->includeFilePageElement->setSource(TEST_SRC_PATH . '/resources/contentFile.txt'); 61 $this->assertEqual ($this->includeFilePageElement->process(), 'This is the content.');76 $this->assertEquals('This is the content.', $this->includeFilePageElement->process()); 62 77 } 63 78 } trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisPageElementTestCase.php
r1231 r1262 8 8 */ 9 9 stubClassLoader::load('net::stubbles::websites::memphis::stubMemphisPageElement'); 10 Mock::generate('stubRequest');11 Mock::generate('stubSession');12 Mock::generate('stubResponse');13 10 /** 14 11 * Class to get a non-abstract class to test. … … 35 32 * @subpackage websites_memphis_test 36 33 */ 37 class stubMemphisPageElementTestCase extends UnitTestCase34 class stubMemphisPageElementTestCase extends PHPUnit_Framework_TestCase 38 35 { 39 36 /** … … 46 43 * mocked request instance 47 44 * 48 * @var SimpleMock45 * @var PHPUnit_Framework_MockObject_MockObject 49 46 */ 50 47 protected $mockRequest; … … 52 49 * mocked session instance 53 50 * 54 * @var SimpleMock51 * @var PHPUnit_Framework_MockObject_MockObject 55 52 */ 56 53 protected $mockSession; … … 58 55 * mocked response instance 59 56 * 60 * @var SimpleMock57 * @var PHPUnit_Framework_MockObject_MockObject 61 58 */ 62 59 protected $mockResponse; … … 67 64 public function setUp() 68 65 { 69 $this->mockRequest = new MockstubRequest();70 $this->mockSession = new MockstubSession();71 $this->mockResponse = new MockstubResponse();66 $this->mockRequest = $this->getMock('stubRequest'); 67 $this->mockSession = $this->getMock('stubSession'); 68 $this->mockResponse = $this->getMock('stubResponse'); 72 69 $this->memphisPageElement = new TeststubMemphisPageElement(); 73 70 } … … 75 72 /** 76 73 * assure that a memphis page element is always available for the correct part 74 * 75 * @test 77 76 */ 78 public function testIsAvailable()77 public function isAvailable() 79 78 { 80 79 $context = array('part' => 'dummy'); trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php
r1249 r1262 8 8 */ 9 9 stubClassLoader::load('net::stubbles::websites::memphis::stubMemphisProcessor'); 10 Mock::generate('stubRequest'); 11 Mock::generate('stubSession'); 12 Mock::generate('stubPage'); 13 Mock::generate('stubPageElement'); 14 Mock::generate('stubPageFactory'); 15 Mock::generate('stubMemphisConfig'); 16 Mock::generate('stubMemphisTemplate'); 17 Mock::generate('stubWebsiteCache'); 18 Mock::generatePartial('stubMemphisProcessor', 19 'PartialMockstubMemphisProcessor', 20 array('createTemplate', 21 'getPageName', 22 'getFrameId', 23 'processCacheVars', 24 'setTemplateVars', 25 'processPageElements' 26 ) 27 ); 10 class TeststubMemphisConfig extends stubMemphisConfig 11 { 12 public function __construct() { } 13 } 14 class TeststubMemphisTemplate extends stubMemphisTemplate 15 { 16 /** 17 * constructor 18 * 19 * @param string $baseDir directory where template files can be found 20 * @param array $namespaces optional namespaces for patTemplate tags, default patTemplate 21 * @param array $options optional configuration options for patTemplate 22 */ 23 public function __construct($baseDir, array $namespaces = array(), array $options = array()) { } 24 } 28 25 /** 29 26 * Extend tested class to be able to inject mock instances. … … 140 137 * @subpackage websites_memphis_test 141 138 */ 142 class Test PartialMockstubMemphisProcessor extends PartialMockstubMemphisProcessor139 class Test2stubMemphisProcessor extends stubMemphisProcessor 143 140 { 144 141 /** … … 156 153 $this->response = $response; 157 154 $this->pageFactory = $pageFactory; 158 parent::__construct();159 155 } 160 156 … … 186 182 * @subpackage websites_memphis_test 187 183 */ 188 class stubMemphisProcessorTestCase extends UnitTestCase184 class stubMemphisProcessorTestCase extends PHPUnit_Framework_TestCase 189 185 { 190 186 /** … … 197 193 * mocked request instance 198 194 * 199 * @var SimpleMock195 * @var PHPUnit_Framework_MockObject_MockObject 200 196 */ 201 197 protected $mockRequest; … … 203 199 * mocked session instance 204 200 * 205 * @var SimpleMock201 * @var PHPUnit_Framework_MockObject_MockObject 206 202 */ 207 203 protected $mockSession; … … 209 205 * mocked response instance 210 206 * 211 * @var SimpleMock207 * @var PHPUnit_Framework_MockObject_MockObject 212 208 */ 213 209 protected $mockResponse; … … 215 211 * mocked page factory instance 216 212 * 217 * @var SimpleMock213 * @var PHPUnit_Framework_MockObject_MockObject 218 214 */ 219 215 protected $mockPageFactory; … … 221 217 * mocked page configuration instance 222 218 * 223 * @var SimpleMock219 * @var PHPUnit_Framework_MockObject_MockObject 224 220 */ 225 221 protected $mockPage; … … 227 223 * mocked memphis config instance 228 224 * 229 * @var SimpleMock225 * @var PHPUnit_Framework_MockObject_MockObject 230 226 */ 231 227 protected $mockMemphisConfig; … … 233 229 * mocked memphis template instance 234 230 * 235 * @var SimpleMock231 * @var PHPUnit_Framework_MockObject_MockObject 236 232 */ 237 233 protected $mockMemphisTemplate; … … 242 238 public function setUp() 243 239 { 244 $this->mockRequest = new MockstubRequest();245 $this->mockSession = new MockstubSession();246 $this->mockResponse = new MockstubResponse();247 $this->mockPageFactory = new MockstubPageFactory();240 $this->mockRequest = $this->getMock('stubRequest'); 241 $this->mockSession = $this->getMock('stubSession'); 242 $this->mockResponse = $this->getMock('stubResponse'); 243 $this->mockPageFactory = $this->getMock('stubPageFactory'); 248 244 $this->memphisProcessor = new TeststubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse, $this->mockPageFactory); 249 $this->mockMemphisConfig = new MockstubMemphisConfig();245 $this->mockMemphisConfig = $this->getMock('TeststubMemphisConfig'); 250 246 $this->memphisProcessor->setConfig($this->mockMemphisConfig); 251 $this->mockMemphisTemplate = new MockstubMemphisTemplate();247 $this->mockMemphisTemplate = $this->getMock('TeststubMemphisTemplate', array(), array('')); 252 248 $this->memphisProcessor->setTemplate($this->mockMemphisTemplate); 253 $this->mockPage = new MockstubPage();254 $this->mockPageFactory-> setReturnValue('getPage', $this->mockPage);249 $this->mockPage = $this->getMock('stubPage'); 250 $this->mockPageFactory->expects($this->any())->method('getPage')->will($this->returnValue($this->mockPage)); 255 251 } 256 252 … … 260 256 public function testDoProcessWithoutCache() 261 257 { 262 $memphisProcessor = new TestPartialMockstubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse, $this->mockPageFactory); 258 $memphisProcessor = $this->getMock('Test2stubMemphisProcessor', 259 array('createTemplate', 260 'getPageName', 261 'getFrameId', 262 'processCacheVars', 263 'setTemplateVars', 264 'processPageElements' 265 ), 266 array($this->mockRequest, 267 $this->mockSession, 268 $this->mockResponse, 269 $this->mockPageFactory 270 ) 271 ); 263 272 $memphisProcessor->setConfig($this->mockMemphisConfig); 264 $memphisProcessor->setReturnValue('createTemplate', $this->mockMemphisTemplate); 265 $memphisProcessor->setReturnValue('getPageName', 'foo'); 266 $memphisProcessor->setReturnValue('getFrameId', 'bar'); 267 $mockPageElement = new MockstubPageElement(); 268 $this->mockPage->setReturnValue('getElements', array('baz' => $mockPageElement)); 269 $memphisProcessor->expectNever('processCacheVars'); 270 $this->mockMemphisConfig->expectOnce('getFrame', array('bar')); 271 $this->mockMemphisConfig->setReturnValue('getFrame', 'frame/default.tmpl'); 272 $this->mockMemphisTemplate->expectOnce('readTemplatesFromInput', array('frame/default.tmpl')); 273 $memphisProcessor->expectOnce('setTemplateVars', array('*', 'foo', 'bar')); 274 $memphisProcessor->expectOnce('processPageElements', array('*', array('baz' => $mockPageElement), '*')); 275 $this->mockResponse->expectNever('getData'); 276 $this->mockResponse->expectNever('replaceData'); 273 $memphisProcessor->expects($this->once())->method('createTemplate')->will($this->returnValue($this->mockMemphisTemplate)); 274 $memphisProcessor->expects($this->any())->method('getPageName')->will($this->returnValue('foo')); 275 $memphisProcessor->expects($this->any())->method('getFrameId')->will($this->returnValue('bar')); 276 $mockPageElement = $this->getMock('stubPageElement'); 277 $this->mockPage->expects($this->any())->method('getElements')->will($this->returnValue(array('baz' => $mockPageElement))); 278 $memphisProcessor->expects($this->never())->method('processCacheVars'); 279 $this->mockMemphisConfig->expects($this->once())->method('getFrame')->with($this->equalTo('bar'))->will($this->returnValue('frame/default.tmpl')); 280 $this->mockMemphisTemplate->expects($this->once())->method('readTemplatesFromInput')->with($this->equalTo('frame/default.tmpl')); 281 $memphisProcessor->expects($this->once())->method('setTemplateVars'); 282 $memphisProcessor->expects($this->once())->method('processPageElements'); 283 $this->mockResponse->expects($this->never())->method('getData'); 284 $this->mockResponse->expects($this->never())->method('replaceData'); 277 285 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 278 286 } … … 281 289 * test the processing algorithm using a cache 282 290 */ 283 public function testDoProcessWithCacheButUncached() 284 { 285 $memphisProcessor = new TestPartialMockstubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse, $this->mockPageFactory); 291 /*public function testDoProcessWithCacheButUncached() 292 { 293 $memphisProcessor = $this->getMock('Test2stubMemphisProcessor', 294 array('createTemplate', 295 'getPageName', 296 'getFrameId', 297 'processCacheVars', 298 'setTemplateVars', 299 'processPageElements' 300 ), 301 array($this->mockRequest, 302 $this->mockSession, 303 $this->mockResponse, 304 $this->mockPageFactory 305 ) 306 ); 286 307 $memphisProcessor->setConfig($this->mockMemphisConfig); 287 $memphisProcessor->setReturnValue('createTemplate', $this->mockMemphisTemplate); 288 $memphisProcessor->setReturnValue('getPageName', 'foo'); 289 $memphisProcessor->setReturnValue('getFrameId', 'bar'); 290 $mockPageElement = new MockstubPageElement(); 291 $this->mockPage->setReturnValue('getElements', array('baz' => $mockPageElement)); 308 $memphisProcessor->expects($this->once())->method('createTemplate')->will($this->returnValue($this->mockMemphisTemplate)); 309 $memphisProcessor->expects($this->any())->method('getPageName')->will($this->returnValue('foo')); 310 $memphisProcessor->expects($this->any())->method('getFrameId')->will($this->returnValue('bar')); 311 $mockPageElement = $this->getMock('stubPageElement'); 312 $this->mockPage->expects($this->any())->method('getElements')->will($this->returnValue(array('baz' => $mockPageElement))); 313 // start here 292 314 $memphisProcessor->expectOnce('processCacheVars', array('*', array('baz' => $mockPageElement), 'foo', 'bar', '*')); 293 315 $memphisProcessor->setReturnValue('processCacheVars', true); … … 308 330 $this->mockResponse->expectOnce('replaceData', array('name=idnameid')); 309 331 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 310 } 332 }*/ 311 333 312 334 /** 313 335 * test the processing algorithm using a cache 314 336 */ 315 public function testDoProcessWithCacheButUncachableElement()337 /*public function testDoProcessWithCacheButUncachableElement() 316 338 { 317 339 $memphisProcessor = new TestPartialMockstubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse, $this->mockPageFactory); … … 339 361 $this->mockResponse->expectOnce('replaceData', array('name=idnameid')); 340 362 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 341 } 363 }*/ 342 364 343 365 /** 344 366 * test the processing algorithm using a cache 345 367 */ 346 public function testDoProcessWithCacheAndCached()368 /*public function testDoProcessWithCacheAndCached() 347 369 { 348 370 $memphisProcessor = new TestPartialMockstubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse, $this->mockPageFactory); … … 367 389 $this->mockResponse->expectNever('replaceData'); 368 390 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 369 } 391 }*/ 370 392 371 393 /** 372 394 * test that collecting the cache variables works as expected 373 395 */ 374 public function testProcessCacheVars()396 /*public function testProcessCacheVars() 375 397 { 376 398 $prefixRequest = new stubRequestPrefixDecorator($this->mockRequest, ''); … … 435 457 $this->memphisProcessor->setWebsiteCache($mockCache); 436 458 $this->assertTrue($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'foo', 'bar', array())); 437 } 459 }*/ 438 460 439 461 /** 440 462 * test that collecting the cache variables works as expected 441 463 */ 442 public function testProcessCacheVarsWithUncachableElement()464 /*public function testProcessCacheVarsWithUncachableElement() 443 465 { 444 466 $prefixRequest = new stubRequestPrefixDecorator($this->mockRequest, ''); … … 485 507 $this->memphisProcessor->setWebsiteCache($mockCache); 486 508 $this->assertFalse($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'foo', 'bar', array())); 487 } 509 }*/ 488 510 489 511 /** 490 512 * test that collecting the cache variables works as expected 491 513 */ 492 public function testProcessCacheVarsWithUncachableDefaultElement()514 /*public function testProcessCacheVarsWithUncachableDefaultElement() 493 515 { 494 516 $prefixRequest = new stubRequestPrefixDecorator($this->mockRequest, ''); … … 532 554 $this->memphisProcessor->setWebsiteCache($mockCache); 533 555 $this->assertFalse($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'foo', 'bar', array())); 534 } 556 }*/ 535 557 536 558 /** 537 559 * test that processing of page elements works as expected 538 560 */ 539 public function testProcessPageElements()561 /*public function testProcessPageElements() 540 562 { 541 563 $prefixRequest = new stubRequestPrefixDecorator($this->mockRequest, ''); … … 578 600 $this->mockResponse->expectOnce('write', array('defaultMock2Mock2defaultMock2Mock2')); 579 601 $this->memphisProcessor->callProcessPageElements($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), array()); 580 } 602 }*/ 581 603 582 604 /** 583 605 * test that processing of page elements works as expected 584 606 */ 585 public function testProcessPageElementsWithRequestCancelledByPageElement()607 /*public function testProcessPageElementsWithRequestCancelledByPageElement() 586 608 { 587 609 $prefixRequest = new stubRequestPrefixDecorator($this->mockRequest, ''); … … 618 640 $this->mockResponse->expectNever('write'); 619 641 $this->memphisProcessor->callProcessPageElements($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), array()); 620 } 642 }*/ 621 643 622 644 /** 623 645 * test that processing of page elements works as expected 624 646 */ 625 public function testProcessPageElementsWithRequestCancelledByDefaultPageElement()647 /*public function testProcessPageElementsWithRequestCancelledByDefaultPageElement() 626 648 { 627 649 $prefixRequest = new stubRequestPrefixDecorator($this->mockRequest, ''); … … 653 675 $this->mockResponse->expectNever('write'); 654 676 $this->memphisProcessor->callProcessPageElements($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), array()); 655 } 677 }*/ 656 678 657 679 /** 658 680 * test that request is responsible for choosing the frame 659 681 */ 660 public function testGetFrameIdFromRequest()682 /*public function testGetFrameIdFromRequest() 661 683 { 662 684 $this->mockMemphisConfig->setReturnValue('getFrames', array('default' => 'frame/default.tmpl')); … … 670 692 $this->assertEqual($this->memphisProcessor->callGetFrameId($page), 'default'); 671 693 $this->assertEqual($this->memphisProcessor->callGetFrameId($page), 'default'); 672 } 694 }*/ 673 695 674 696 /** 675 697 * test that session is responsible for choosing the frame 676 698 */ 677 public function testGetFrameIdFromSession()699 /*public function testGetFrameIdFromSession() 678 700 { 679 701 $page = new stubPage(); … … 687 709 $this->assertEqual($this->memphisProcessor->callGetFrameId($page), 'default'); 688 710 $this->assertEqual($this->memphisProcessor->callGetFrameId($page), 'default'); 689 } 711 }*/ 690 712 691 713 /** 692 714 * test that page is responsible for choosing the frame 693 715 */ 694 public function testGetFrameIdFromPage()716 /*public function testGetFrameIdFromPage() 695 717 { 696 718 $page = new stubPage(); … … 704 726 $page->setProperty('frame', 'another'); 705 727 $this->assertEqual($this->memphisProcessor->callGetFrameId($page), 'another'); 706 } 728 }*/ 707 729 708 730 /** 709 731 * test that page is responsible for choosing the frame 710 732 */ 711 public function testGetFrameIdFromPageWithFixedFrame()733 /*public function testGetFrameIdFromPageWithFixedFrame() 712 734 { 713 735 $page = new stubPage(); … … 717 739 $this->mockSession->expectNever('hasValue'); 718 740 $this->assertEqual($this->memphisProcessor->callGetFrameId($page), '404'); 719 } 741 }*/ 720 742 721 743 /** 722 744 * test that template vars are set correct 723 745 */ 724 public function testSetTemplateVars1()746 /*public function testSetTemplateVars1() 725 747 { 726 748 $this->mockMemphisConfig->setReturnValue('getMetaTags', array('description' => 'This is a description.', … … 744 766 $page->setProperty('title', 'bar'); 745 767 $this->memphisProcessor->callSetTemplateVars($page, 'baz', 'foo'); 746 } 768 }*/ 747 769 748 770 /** 749 771 * test that template vars are set correct 750 772 */ 751 public function testSetTemplateVars2()773 /*public function testSetTemplateVars2() 752 774 { 753 775 $mockCache = new MockstubWebsiteCache(); … … 770 792 $page->setProperty('title', 'bar'); 771 793 $this->memphisProcessor->callSetTemplateVars($page, 'baz', 'foo'); 772 } 794 }*/ 773 795 } 774 796 ?>
