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 testSaveArrayToFile() { MockTest::inject($this->yaml, 'tmpDir'); $file = MockTest::mockFile('anyFile.php'); MockTest::callMockMethod($this->yaml, 'saveArrayToFile', [$file, ['anyArray']]); $this->assertEquals(['anyArray'], include $file); }
public function testJoin() { $stub = \Mockery::mock('alias:\\Doctrine\\ORM\\QueryBuilder'); $stub->shouldReceive('join')->andReturnSelf()->once(); $this->_queryBuilder = new QueryBuilder($this->getMockIQueryController($stub)); MockTest::callMockMethod($this->_queryBuilder, 'join', ['column']); }
public function testSetBreadcrumbsArray() { $this->mockCategoryList(['anyCategory']); MockTest::callMockMethod($this->_categoryBc, 'setBreadcrumbsArray'); $breadcrumbsArray = \PHPUnit_Framework_Assert::readAttribute($this->_categoryBc, 'breadcrumbsArray'); $this->assertEquals(['anyCategory'], $breadcrumbsArray); }
public function testAliasExistsInDB() { $alias = 'new-post'; MockDoctrine::getRepositoryResult([$alias]); $this->_alias = new Alias(new \Entity\Posts()); $aliasNotExistsInDB = MockTest::callMockMethod($this->_alias, 'isAliasNotExistsInDB', [$alias]); $this->assertFalse($aliasNotExistsInDB); }
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 testAddBreadcrumb() { $arg = ['anyTitle', 'AnyLink']; $addBreadcrumb = MockTest::callMockMethod($this->ibc, 'addBreadcrumb', $arg); $this->assertInstanceOf('stdClass', $addBreadcrumb); $this->assertEquals('anyTitle', $addBreadcrumb->title); $this->assertEquals('AnyLink', $addBreadcrumb->link); $this->assertEquals('', $addBreadcrumb->active); }
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 testIsArrayNotEmpty() { $args = array('', '', 1, ''); $isArrayNotEmpty = Mock\MockTest::callMockMethod($this->_controller, 'isArrayNotEmpty', array($args)); $this->assertEquals(1, $isArrayNotEmpty); $args = array('', '', 0, ''); $isArrayNotEmpty = Mock\MockTest::callMockMethod($this->_controller, 'isArrayNotEmpty', array($args)); $this->assertEquals(0, $isArrayNotEmpty); }
public function testAddActiveClass() { $object = new \stdClass(); $object->link = 'anyLink'; $breadcrumbs = ['', $object]; $addActiveClass = MockTest::callMockMethod($this->bc, 'addActiveClass', [$breadcrumbs]); $this->assertEquals('active', $addActiveClass[1]->active); $this->assertEquals('', $addActiveClass[1]->link); }
public function testCutString() { $string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ultrices enim turpis, in auctor massa dictum sit amet. In hac habitasse platea dictumst."; $cutString = MockTest::callMockMethod($this->_handler, 'cutString', array($string)); $this->assertEquals("Lorem ipsum dolor sit amet, consectetur ...", $cutString); $string = "Lorem ipsum dolor sit amet, consectetur"; $cutString = MockTest::callMockMethod($this->_handler, 'cutString', array($string)); $this->assertEquals("Lorem ipsum dolor sit amet, consectetur", $cutString); }
public function testLoadLogDisplayWithBacktrace() { MockTest::injectStatic('Ignaszak\\Exception\\Controller\\IController', 'errorArray', [0 => ['type' => 'Warning', 'message' => 'anyMessage', 'file' => 'anyFile', 'line' => 1, 'trace' => [0 => ['message' => 'backtraceMEssage', 'file' => 'backtraceFile', 'arguments' => 'anyArguments']]]]); $result = MockTest::callMockMethod($this->_logFile, 'loadLogDisplay'); $this->assertEquals(['errors' => <<<EOT #1 [Warning] anyMessage in anyFile on line 1 [Backtrace]: backtraceMEssage IN: backtraceFile ARGUMENTS: anyArguments EOT , 'errorsCount' => 1], $result); MockTest::injectStatic('Ignaszak\\Exception\\Controller\\IController', 'errorArray', []); }
private function getRegistryInstance(string $registry) { return MockTest::callMockMethod('Ignaszak\\Registry\\RegistryFactory', 'getRegistryInstance', [$registry]); }
public function testGetEmailEntityGetter() { $this->assertEquals('getEmail', MockTest::callMockMethod($this->user, 'getEntityGetter', ['userEmail'])); }
private function getInf(string $inf) : string { return MockTest::callMockMethod($this->display, 'getInf', array($inf)); }
public function testDir() { $this->assertEquals('/anyDir', MockTest::callMockMethod($this->_load, 'dir', ['/anyDir'])); }
/** * @expectedException \RuntimeException */ public function testGetFormGroupWithNoExistingGroupForm() { $this->_form->createForm('noExistingGroup-action'); MockTest::callMockMethod($this->_form, 'getFormGroup'); }
public function testGetFormActionFromGroup() { $this->mockGroup('anyGroupWithoutAction'); $action = MockTest::callMockMethod($this->group, 'getFormAction'); $this->assertEquals('anyGroupWithoutAction', $action); }
/** * @expectedException \Ignaszak\Router\RouterException */ public function testUnableToSaveTmpRoute() { $file = MockTest::mockFile('file.php', 0444); MockTest::callMockMethod($this->cache, 'saveTmpRoute', [$file, []]); }
public function testIsUserNotReporting() { MockTest::injectStatic($this->_controller, 'reportedErrorCode', E_NOTICE); MockTest::mockConf('userReporting', E_ALL & ~E_NOTICE); $this->assertFalse(MockTest::callMockMethod($this->_controller, 'isUserReporting')); }
public function testModRewriteEnable() { putenv("HTTP_MOD_REWRITE=On"); $this->assertTrue(MockTest::callMockMethod($this->valid, 'isModRewriteEnabled')); }
public function testCreateMenuFromMenuItemsArray() { $menuString = MockTest::callMockMethod(self::$menu, 'createMenu', ['']); $this->assertNotEmpty($menuString); $this->assertTrue(is_string($menuString)); }
private function formatData(string $value, string $key) : string { return MockTest::callMockMethod('Ignaszak\\Exception\\Modules\\Variable', 'formatServerDataValue', [$value, $key]); }
public function testSetError() { MockTest::callMockMethod($this->validator, 'setError', ['anyError1']); MockTest::callMockMethod($this->validator, 'setError', ['anyError2']); $this->assertEquals(['anyError1' => 1, 'anyError2' => 1], $this->validator->getErrors()); }
public function testValidLink() { $this->assertTrue(MockTest::callMockMethod($this->urlGenerator, 'validLink', ['/anyLink/with/replaced/token/', 'routName'])); }
private function httpMethod(string $route, string $current) : bool { $result = MockTest::callMockMethod($this->matcher, 'httpMethod', [$route, $current]); return $result; }
public function testBegin() { MockTest::inject($this->_fileContent, 'offset', 10); MockTest::inject($this->_fileContent, 'line', 66); $this->assertEquals(56, MockTest::callMockMethod($this->_fileContent, 'getBegin')); }
public function testLoadExtensionConfFileArray() { $structure = ['Menu' => ['router.yml' => '', 'conf.yml' => ''], 'Post' => ['router.yml' => '', 'conf.yml' => ''], 'Page' => ['router.yml' => '', 'conf.yml' => '']]; MockTest::callMockMethod($this->_adminExtension, 'loadExtensionArray', [MockTest::mockFileSystem($structure)]); $this->assertEquals([2 => 'Menu', 3 => 'Page', 4 => 'Post'], \PHPUnit_Framework_Assert::readAttribute($this->_adminExtension, 'extensionsArray')); }
private function getErrorTypeByNumber(int $errorType) : string { return MockTest::callMockMethod($this->_errorHandler, 'getErrorTypeByNumber', array($errorType)); }
public function testGetPatterns() { MockTest::inject($this->converter, 'routeArray', ['patterns' => ['pattern' => 'regex']]); $this->assertTrue(array_key_exists('@pattern', MockTest::callMockMethod($this->converter, 'getPatterns'))); }