Example #1
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']);
 }
Example #2
0
 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);
 }
Example #3
0
 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']);
 }
Example #4
0
 public function testSetBreadcrumbsArray()
 {
     $this->mockCategoryList(['anyCategory']);
     MockTest::callMockMethod($this->_categoryBc, 'setBreadcrumbsArray');
     $breadcrumbsArray = \PHPUnit_Framework_Assert::readAttribute($this->_categoryBc, 'breadcrumbsArray');
     $this->assertEquals(['anyCategory'], $breadcrumbsArray);
 }
Example #5
0
 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);
 }
Example #6
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);
 }
Example #7
0
 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);
 }
Example #8
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');
 }
 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);
 }
Example #10
0
 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);
 }
Example #11
0
 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);
 }
Example #12
0
    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]);
 }
Example #14
0
 public function testGetEmailEntityGetter()
 {
     $this->assertEquals('getEmail', MockTest::callMockMethod($this->user, 'getEntityGetter', ['userEmail']));
 }
Example #15
0
 private function getInf(string $inf) : string
 {
     return MockTest::callMockMethod($this->display, 'getInf', array($inf));
 }
Example #16
0
 public function testDir()
 {
     $this->assertEquals('/anyDir', MockTest::callMockMethod($this->_load, 'dir', ['/anyDir']));
 }
Example #17
0
 /**
  * @expectedException \RuntimeException
  */
 public function testGetFormGroupWithNoExistingGroupForm()
 {
     $this->_form->createForm('noExistingGroup-action');
     MockTest::callMockMethod($this->_form, 'getFormGroup');
 }
Example #18
0
 public function testGetFormActionFromGroup()
 {
     $this->mockGroup('anyGroupWithoutAction');
     $action = MockTest::callMockMethod($this->group, 'getFormAction');
     $this->assertEquals('anyGroupWithoutAction', $action);
 }
Example #19
0
 /**
  * @expectedException \Ignaszak\Router\RouterException
  */
 public function testUnableToSaveTmpRoute()
 {
     $file = MockTest::mockFile('file.php', 0444);
     MockTest::callMockMethod($this->cache, 'saveTmpRoute', [$file, []]);
 }
Example #20
0
 public function testIsUserNotReporting()
 {
     MockTest::injectStatic($this->_controller, 'reportedErrorCode', E_NOTICE);
     MockTest::mockConf('userReporting', E_ALL & ~E_NOTICE);
     $this->assertFalse(MockTest::callMockMethod($this->_controller, 'isUserReporting'));
 }
Example #21
0
 public function testModRewriteEnable()
 {
     putenv("HTTP_MOD_REWRITE=On");
     $this->assertTrue(MockTest::callMockMethod($this->valid, 'isModRewriteEnabled'));
 }
Example #22
0
 public function testCreateMenuFromMenuItemsArray()
 {
     $menuString = MockTest::callMockMethod(self::$menu, 'createMenu', ['']);
     $this->assertNotEmpty($menuString);
     $this->assertTrue(is_string($menuString));
 }
Example #23
0
 private function formatData(string $value, string $key) : string
 {
     return MockTest::callMockMethod('Ignaszak\\Exception\\Modules\\Variable', 'formatServerDataValue', [$value, $key]);
 }
Example #24
0
 public function testSetError()
 {
     MockTest::callMockMethod($this->validator, 'setError', ['anyError1']);
     MockTest::callMockMethod($this->validator, 'setError', ['anyError2']);
     $this->assertEquals(['anyError1' => 1, 'anyError2' => 1], $this->validator->getErrors());
 }
Example #25
0
 public function testValidLink()
 {
     $this->assertTrue(MockTest::callMockMethod($this->urlGenerator, 'validLink', ['/anyLink/with/replaced/token/', 'routName']));
 }
Example #26
0
 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'));
 }
Example #28
0
 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));
 }
Example #30
0
 public function testGetPatterns()
 {
     MockTest::inject($this->converter, 'routeArray', ['patterns' => ['pattern' => 'regex']]);
     $this->assertTrue(array_key_exists('@pattern', MockTest::callMockMethod($this->converter, 'getPatterns')));
 }