writer = new WactCodeWriter(); } function testGetCode() { $this->assertEqual($this->writer->renderCode(),''); } function testGetSetCode() { $this->writer->setCode($code = 'code'); $this->assertEqual($code, $this->writer->getCode()); } function testWritePHP() { $this->writer->writePHP('echo ("Hello World!");'); $this->assertEqual($this->writer->renderCode(),''); } function testWriteHTML() { $this->writer->writeHTML('

Hello World!

'); $this->assertEqual($this->writer->renderCode(),'

Hello World!

'); } function testSwithBetweenPHPAndHTML() { $this->writer->writePHP('echo ("Hello World!");'); $this->writer->writeHTML('

Hello World!

'); $this->writer->writePHP('echo ("Hello World!");'); $this->assertEqual($this->writer->renderCode(), '

Hello World!

'); } function testRegisterInclude() { $this->writer->registerInclude('test.php'); $this->assertEqual($this->writer->renderCode(),''); } function testReset() { $this->writer->writePHP('echo ("Hello World!");'); $this->writer->registerInclude('test.php'); $this->writer->reset(); $this->assertEqual($this->writer->renderCode(), ''); } function testBeginFunction() { $params = '($a,$b,$c)'; $this->writer->beginFunction($params); $this->assertEqual($this->writer->renderCode(),'"); } function testEndFunction() { $this->writer->endFunction(); $this->assertEqual($this->writer->renderCode(),''); } function testSetFunctionPrefix() { $this->writer->setFunctionPrefix('Test'); $params = '($a,$b,$c)'; $this->writer->beginFunction($params); $this->assertEqual($this->writer->renderCode(),'"); } function testGetTempVariable() { $var = $this->writer->getTempVariable(); $this->assertWantedPattern('/[a-z][a-z0-9]*/i', $var); } function testGetSecondTempVariable() { $A = $this->writer->getTempVariable(); $B = $this->writer->getTempVariable(); $this->assertNotEqual($A, $B); } function testGetTempVariablesMany() { for ($i = 1; $i <= 30; $i++) { $var = $this->writer->getTempVariable(); $this->assertWantedPattern('/[a-z][a-z0-9]*/i', $var); } } } ?>