/** * Getter for the View instance variable. * * @return MvcLite\View */ public function getView() { if (!$this->view) { $this->view = \MvcLite\View::getInstance(); } return $this->view; }
/** * The setup method, called before each test */ public function setUp() { $this->sut = View::getInstance(); }
/** * Tests the MvcLite\View::getHelper method. * * @dataProvider provideGetHelper * @runInSeparateProcess */ public function testGetHelper($helper, $helpers = [], $exception = false) { if ($exception) { $this->setExpectedException('\\MvcLite\\Exception'); } $loader = $this->getMockBuilder('\\Composer\\Loader\\Autoloader')->disableOriginalConstructor()->setMethods(['loadClass'])->getMock(); $loader->expects($this->any())->method('loadClass')->will($this->returnValueMap([['\\App\\View\\Helper\\' . ucfirst($helper), false], ['\\MvcLite\\View\\Helper\\' . ucfirst($helper), $exception ? false : true]])); $sut = \MvcLite\View::getInstance(); $this->setReflectionPropertyValue($sut, 'helpers', $helpers); $sut->setLoader($loader); $result = $sut->getHelper($helper); $this->assertInstanceOf('\\MvcLite\\View\\HelperAbstract', $result); }