public function testGetAdminExtensionsRouteYaml() { $structure = ['Menu' => ['router.yml' => '', 'conf.yml' => ''], 'Post' => ['router.yml' => '', 'conf.yml' => ''], 'Page' => ['conf.yml' => '']]; $this->_adminExtension = new AdminExtension(MockTest::mockFileSystem($structure)); MockTest::inject($this->_adminExtension, 'extensionsArray', ['Menu', 'Page', 'Post']); $this->assertEquals(['vfs://mock/Menu/router.yml', 'vfs://mock/Post/router.yml'], $this->_adminExtension->getAdminExtensionsRouteYaml()); }
public function testGetSetterValue() { $command = \PHPUnit_Framework_Assert::readAttribute($this->validator, 'command'); MockTest::inject($command, 'entitySettersArray', ['setTitle' => 'value of setter']); $setter = MockTest::callMockMethod($this->validator, 'getSetter', ['title']); $this->assertEquals('value of setter', $setter); }
public function testLoadHttp() { MockTest::inject($this->_load, 'conf', ['conf' => ['tmp' => ['router' => MockTest::mockFileSystem([''])]]]); MockTest::inject($this->_load, 'routerYaml', MockTest::mockFile('router.yml')); $this->_load->loadHttp(); $this->assertInstanceOf('App\\Resource\\Http', \PHPUnit_Framework_Assert::readAttribute($this->_load, 'http')); }
public function testReadFromTmpFile() { $yamlFile = MockTest::mockFile('anyFile.yml'); $structure = MockTest::mockFileSystem([md5($yamlFile) . '.php' => "<?php return ['anyArray'];"]); MockTest::inject($this->yaml, 'tmpDir', $structure); $this->assertEquals(['anyArray'], $this->yaml->parse($yamlFile)); }
public function test__call() { $stub = \Mockery::mock('SwiftMessage'); $stub->shouldReceive('setSubject'); MockTest::inject($this->mail, 'swiftMessage', $stub); $this->mail->setSubject(); }
public function testAddErrorsArray() { MockTest::inject($this->validatorFactory, 'errorArray', ['anyKey' => 'initState']); $errors = ['anyKey2' => 'anyErrors']; MockTest::callMockMethod($this->validatorFactory, 'addErrors', [$errors]); $this->assertEquals(\PHPUnit_Framework_Assert::readAttribute($this->validatorFactory, 'errorArray'), ['anyKey' => 'initState', 'anyKey2' => 'anyErrors']); }
public function testDataExistsInDatabaseWithException() { $stub = $this->mockQuery(['value']); $stub->shouldReceive('query')->once(); MockTest::inject($this->uniqueValidator, 'query', $stub); $result = MockTest::callMockMethod($this->uniqueValidator, 'dataNotExistInDatabase', ['column', 'value', ['exception']]); $this->assertFalse($result); }
public function testLoadFile() { MockTest::inject($this->display, 'baseDir'); // Clear baseDir for mock file $file = MockTest::mockFile('AnyThemeFile.php', 0777, '<?php new \\Test\\TestLoadCount; ?>'); MockTest::callMockMethod($this->display, 'load', array($file)); $this->assertEquals(1, TestLoadCount::$count); }
public function testCatchException() { $stub = \Mockery::mock('Load'); $stub->shouldReceive('getExceptionHandler')->once()->andReturnSelf(); $stub->shouldReceive('catchException')->once(); MockTest::inject($this->app, 'load', $stub); $this->app->catchException(null); }
public function testLoadUserMessageWhenUserIsReporting() { // Clear counter to call again destructor MockTest::injectStatic($this->_controller, 'count'); MockTest::mockConf('userReporting', E_ALL); MockTest::inject($this->_controller, '_logFile', $this->mockLogFile("once")); MockTest::inject($this->_controller, '_display', $this->mockDisplay(2)); $this->_controller->__destruct(); }
public function testSetLimit() { $em = \Mockery::mock('EntityManager'); $em->shouldReceive('setMaxResults')->once(); MockTest::inject($this->_queryController, 'query', $em); $anyLimit = 1; $this->_queryController->limit($anyLimit); MockTest::callMockMethod($this->_queryController, 'setLimit'); }
public function testAddAccountValue() { $stub = \Mockery::mock('ViewHelper\\User'); $stub->shouldReceive('getUserSession')->andReturnSelf()->once(); $stub->shouldReceive('getLogin')->once(); $stub->shouldReceive('getEmail')->once(); $this->user = new User($this->mockForm('accountData')); MockTest::inject($this->user, 'user', $stub); MockTest::callMockMethod($this->user, 'addAccountValue', ['userLogin']); MockTest::callMockMethod($this->user, 'addAccountValue', ['userEmail']); }
public function testGetRouteArray() { MockTest::inject($this->yaml, 'fileArray', [MockTest::mockFile('file.yml')]); $yamlParser = $this->getMockBuilder('Symfony\\Component\\Yaml\\Parser')->disableOriginalConstructor()->getMock(); $yamlParser->expects($this->once())->method('parse')->willReturn([]); MockTest::inject($this->yaml, 'parser', $yamlParser); $stub = $this->getMockBuilder('Ignaszak\\Router\\Matcher\\Converter')->disableOriginalConstructor()->getMock(); $stub->expects($this->once())->method('convert')->willReturn([]); MockTest::inject($this->yaml, 'converter', $stub); $this->yaml->getRouteArray(); }
public static function run(array $data = null) { $_conf = RegistryFactory::start('file')->register('Conf\\Conf'); $array = ['getId' => null, 'getSiteTitle' => '', 'getAdminEmail' => '', 'getViewLimit' => null, 'getDateFormat' => '', 'getBaseUrl' => '', 'getRequestUri' => '', 'getTheme' => '']; if (!is_null($data)) { foreach ($data as $key => $value) { $array[$key] = $value; } } MockTest::inject($_conf, 'optionsArray', $array); }
public function testRunOnDevAndUserMode() { $stub = $this->getMockBuilder('Ignaszak\\Exception\\Handler\\ErrorHandler')->getMock(); $stub->expects($this->once())->method('setErrorHandler'); $stub->expects($this->once())->method('setShutdownHandler'); MockTest::inject($this->start, '_errorHandler', $stub); $stub = $this->getMockBuilder('Ignaszak\\Exception\\Handler\\ExceptionHandler')->getMock(); $stub->expects($this->once())->method('setExceptionHandler'); MockTest::inject($this->start, '_exceptionHandler', $stub); $this->start->display = 'user'; $this->start->run(); }
public function testBegin() { MockTest::inject($this->_fileContent, 'offset', 10); MockTest::inject($this->_fileContent, 'line', 66); $this->assertEquals(56, MockTest::callMockMethod($this->_fileContent, 'getBegin')); }
private function injectMockTransport() { MockTest::inject($this->_mailTransport, 'transportClassName', '\\Test\\Model\\Mail\\MockAnySwiftTransport'); }
public function testGetPatterns() { MockTest::inject($this->converter, 'routeArray', ['patterns' => ['pattern' => 'regex']]); $this->assertTrue(array_key_exists('@pattern', MockTest::callMockMethod($this->converter, 'getPatterns'))); }
public function testGetRouteArray() { $stub = $this->getMockBuilder('Ignaszak\\Router\\Matcher\\Converter')->disableOriginalConstructor()->getMock(); $stub->expects($this->once())->method('convert')->willReturn([]); MockTest::inject($this->route, 'converter', $stub); $this->route->getRouteArray(); }
public function testGetRouteArray() { // Read from converter $this->cache = new Cache($this->mockIRoute('anyChecksum', ['anyRouteArray'])); $tmpDir = MockTest::mockDir('anyDir'); MockTest::inject($this->cache, 'tmpDir', $tmpDir); $this->assertEquals(['anyRouteArray'], $this->cache->getRouteArray()); // Read from cache MockTest::inject($this->cache, 'route', $this->mockIRoute('anyChecksum', ['anyRouteArray'])); $this->assertEquals(['anyRouteArray'], $this->cache->getRouteArray()); }
public function tearDown() { MockTest::inject(Conf::instance(), '_conf'); }
private function mockValidArray(array $array) { MockTest::inject($this->valid, 'validArray', $array); }