/** * @covers Veles\View\Adapters\NativeAdapter::__construct */ public function testConstruct() { $expected = $this->object; $result = $this->object->getDriver(); $msg = 'Wrong NativeAdapter::__construct() behavior!'; $this->assertSame($expected, $result, $msg); }
/** * @covers Veles\View\Adapters\ViewAdapterAbstract::instance * @covers Veles\View\Adapters\ViewAdapterAbstract::invokeLazyCalls */ public function testInstance() { $this->object->addCalls([]); $this->object->setInstance(null); $expected = '\\Veles\\Tests\\View\\Adapters\\ViewAdapterAbstractChild'; $result = $this->object->instance(); $msg = 'ViewAdapterAbstract::instance() returns wrong result!'; $this->assertInstanceOf($expected, $result, $msg); $this->assertAttributeInstanceOf($expected, 'instance', $this->object, $msg); $this->object->setInstance(null); $this->object->addCalls([['method' => 'testCall', 'arguments' => ['string']]]); $result = $this->object->instance(); $msg = 'ViewAdapterAbstract::instance() returns wrong result!'; $this->assertInstanceOf($expected, $result, $msg); $result = $this->object->getCalls(); $this->assertSame([], $result); View::setAdapter(NativeAdapter::instance()); }
<?php /** * Environment initialisation for unit-tests * * @file travisci-nightly-bootstrap.php * * PHP version 7.0+ * * @author Yancharuk Alexander <alex at itvault dot info> * @date 2015-07-29 21:59 * @license The BSD 3-Clause License * <https://tldrlegal.com/license/bsd-3-clause-license-(revised)> */ namespace Veles\Tests; use Veles\AutoLoader; use Veles\View\Adapters\NativeAdapter; use Veles\View\View; define('LIB_DIR', realpath(__DIR__ . '/../..')); define('TEST_DIR', realpath(LIB_DIR . '/Veles/Tests')); date_default_timezone_set('Europe/Moscow'); require LIB_DIR . '/Veles/AutoLoader.php'; $includes = LIB_DIR . ':' . TEST_DIR . ':' . realpath(__DIR__ . '/Project'); set_include_path(implode(PATH_SEPARATOR, [$includes, get_include_path()])); AutoLoader::init(); $view_adapter = new NativeAdapter(); $view_adapter->setTemplateDir(TEST_DIR . '/Project/View/'); View::setAdapter($view_adapter);
/** * @covers Veles\Routing\Route::getAdapter */ public function testGetAdapter() { $this->object->method('getUri')->willReturn('/'); $expected = NativeAdapter::instance(); $result = $this->object->init()->getAdapter(); $msg = 'Route::getAdapter() returns wrong result!'; $this->assertEquals($expected, $result, $msg); }
/** * Unit-test for View::getAdapter * @covers Veles\View\View::getAdapter * @see Veles\View\View::getAdapter */ public function testGetAdapter() { $expected = NativeAdapter::instance(); $_SERVER['REQUEST_URI'] = 'index.html'; $result = View::getAdapter(); $msg = 'Wrong View::getAdapter() result'; $this->assertSame($expected, $result, $msg); $expected = NativeAdapter::instance(); View::unsetAdapter(); View::setAdapter($expected); $result = View::getAdapter(); $this->assertSame($expected, $result, $msg); }