Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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'));
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 public function test__call()
 {
     $stub = \Mockery::mock('SwiftMessage');
     $stub->shouldReceive('setSubject');
     MockTest::inject($this->mail, 'swiftMessage', $stub);
     $this->mail->setSubject();
 }
Esempio n. 6
0
 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']);
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
 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);
 }
Esempio n. 10
0
 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();
 }
Esempio n. 11
0
 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');
 }
Esempio n. 12
0
 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']);
 }
Esempio n. 13
0
 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();
 }
Esempio n. 14
0
 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);
 }
Esempio n. 15
0
 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();
 }
Esempio n. 16
0
 public function testBegin()
 {
     MockTest::inject($this->_fileContent, 'offset', 10);
     MockTest::inject($this->_fileContent, 'line', 66);
     $this->assertEquals(56, MockTest::callMockMethod($this->_fileContent, 'getBegin'));
 }
Esempio n. 17
0
 private function injectMockTransport()
 {
     MockTest::inject($this->_mailTransport, 'transportClassName', '\\Test\\Model\\Mail\\MockAnySwiftTransport');
 }
Esempio n. 18
0
 public function testGetPatterns()
 {
     MockTest::inject($this->converter, 'routeArray', ['patterns' => ['pattern' => 'regex']]);
     $this->assertTrue(array_key_exists('@pattern', MockTest::callMockMethod($this->converter, 'getPatterns')));
 }
Esempio n. 19
0
 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();
 }
Esempio n. 20
0
 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());
 }
Esempio n. 21
0
 public function tearDown()
 {
     MockTest::inject(Conf::instance(), '_conf');
 }
Esempio n. 22
0
 private function mockValidArray(array $array)
 {
     MockTest::inject($this->valid, 'validArray', $array);
 }