public function testGetModel() { $o = new testView(); try { // empty $o->getModel(); } catch (\Exception $e) { $this->assertInstanceOf(Exception::class, $e); $this->assertInstanceOf(ExceptionView::class, $e); } $f = new ModelFixture(); $o->setModel($f); $m = $o->getModel(); $this->assertInstanceOf(ModelA::class, $m); $this->assertInstanceOf(ModelFixture::class, $m); $this->assertEquals($f, $m); }
public function testGetTitleFromModel() { $o = new testView(); try { $this->assertEmpty($o->getTitle()); } catch (\Exception $e) { // catching a model exception } $oMap = new ClassMap(__FILE__, '\\A.*\\Z'); $oMap->setTemplatePath(VSC_FIXTURE_PATH . 'templates/'); $oMap->setTemplate('main.tpl.php'); $o->setMap($oMap); $f = new EmptyModel(); $o->setModel($f); $this->assertEmpty($o->getTitle()); $t = uniqid('test:'); $f->setPageTitle($t); $this->assertEquals($t, $o->getTitle()); }
public function testGetOutput() { $o = new testView(); try { $o->getOutput(); } catch (\Exception $e) { $this->assertInstanceOf(Exception::class, $e); $this->assertInstanceOf(ExceptionView::class, $e); } $t = 'main.tpl.php'; $oMap = new ClassMap(__FILE__, '\\A.*\\Z'); $oMap->setTemplatePath(VSC_FIXTURE_PATH . 'templates/'); $oMap->setTemplate($t); $o->setMap($oMap); $f = new ModelFixture(); $o->setModel($f); $output = $o->getOutput(); $this->assertEquals(file_get_contents(VSC_FIXTURE_PATH . 'templates/' . $t), $output); }