Changeset 1909
- Timestamp:
- 10/28/08 16:51:19 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework/trunk/src/main/php/net/stubbles/websites/stubAbstractPageElement.php
r1902 r1909 6 6 * @package stubbles 7 7 * @subpackage websites 8 * @version $Id$ 8 9 */ 9 10 stubClassLoader::load('net::stubbles::websites::stubPageElement'); … … 46 47 */ 47 48 protected $context; 49 /** 50 * switch whether internal initializing was done or not 51 * 52 * @var bool 53 */ 54 private $initialized = false; 48 55 49 56 /** … … 91 98 $this->response = $response; 92 99 $this->context = $context; 93 $this->doInit(); 100 if (false === $this->initialized) { 101 $this->doInit(); 102 $this->initialized = true; 103 } 94 104 } 95 105 framework/trunk/src/test/php/net/stubbles/websites/stubAbstractPageElementTestCase.php
r1763 r1909 6 6 * @package stubbles 7 7 * @subpackage websites_test 8 * @version $Id$ 8 9 */ 9 10 stubClassLoader::load('net::stubbles::websites::stubAbstractPageElement'); … … 16 17 class TeststubAbstractPageElement extends stubAbstractPageElement 17 18 { 19 /** 20 * counter for calls of doInit() 21 * 22 * @var int 23 */ 24 protected $initCount = 0; 25 18 26 /** 19 27 * returns the request instance … … 54 62 { 55 63 return $this->context; 64 } 65 66 /** 67 * method for additional initialisation 68 */ 69 protected function doInit() 70 { 71 $this->initCount++; 72 } 73 74 /** 75 * returns number of calls to doInit() 76 * 77 * @return int 78 */ 79 public function getInitCount() 80 { 81 return $this->initCount; 56 82 } 57 83 … … 129 155 130 156 /** 157 * doInit() should be called only once regardless of calls to init() 158 * 159 * @test 160 */ 161 public function doInitIsOnlyCalledOnce() 162 { 163 $mockRequest = $this->getMock('stubRequest'); 164 $mockSession = $this->getMock('stubSession'); 165 $mockResponse = $this->getMock('stubResponse'); 166 $this->assertEquals(0, $this->abstractPageElement->getInitCount()); 167 $this->abstractPageElement->init($mockRequest, $mockSession, $mockResponse, array()); 168 $this->assertEquals(1, $this->abstractPageElement->getInitCount()); 169 $this->abstractPageElement->init($mockRequest, $mockSession, $mockResponse, array()); 170 $this->assertEquals(1, $this->abstractPageElement->getInitCount()); 171 } 172 173 /** 131 174 * by default page elements are available, cachable and do not have any cache vars 132 175 *
