예제 #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']);
 }
예제 #2
0
파일: YamlTest.php 프로젝트: ignaszak/cms
 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);
 }
예제 #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']);
 }
예제 #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);
 }
예제 #5
0
파일: AliasTest.php 프로젝트: ignaszak/cms
 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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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');
 }
예제 #9
0
 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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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', []);
    }
예제 #13
0
 private function getRegistryInstance(string $registry)
 {
     return MockTest::callMockMethod('Ignaszak\\Registry\\RegistryFactory', 'getRegistryInstance', [$registry]);
 }
예제 #14
0
파일: UserTest.php 프로젝트: ignaszak/cms
 public function testGetEmailEntityGetter()
 {
     $this->assertEquals('getEmail', MockTest::callMockMethod($this->user, 'getEntityGetter', ['userEmail']));
 }
예제 #15
0
 private function getInf(string $inf) : string
 {
     return MockTest::callMockMethod($this->display, 'getInf', array($inf));
 }
예제 #16
0
파일: LoadTest.php 프로젝트: ignaszak/cms
 public function testDir()
 {
     $this->assertEquals('/anyDir', MockTest::callMockMethod($this->_load, 'dir', ['/anyDir']));
 }
예제 #17
0
파일: FormTest.php 프로젝트: ignaszak/cms
 /**
  * @expectedException \RuntimeException
  */
 public function testGetFormGroupWithNoExistingGroupForm()
 {
     $this->_form->createForm('noExistingGroup-action');
     MockTest::callMockMethod($this->_form, 'getFormGroup');
 }
예제 #18
0
파일: GroupTest.php 프로젝트: ignaszak/cms
 public function testGetFormActionFromGroup()
 {
     $this->mockGroup('anyGroupWithoutAction');
     $action = MockTest::callMockMethod($this->group, 'getFormAction');
     $this->assertEquals('anyGroupWithoutAction', $action);
 }
예제 #19
0
 /**
  * @expectedException \Ignaszak\Router\RouterException
  */
 public function testUnableToSaveTmpRoute()
 {
     $file = MockTest::mockFile('file.php', 0444);
     MockTest::callMockMethod($this->cache, 'saveTmpRoute', [$file, []]);
 }
예제 #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'));
 }
예제 #21
0
파일: ValidTest.php 프로젝트: ignaszak/cms
 public function testModRewriteEnable()
 {
     putenv("HTTP_MOD_REWRITE=On");
     $this->assertTrue(MockTest::callMockMethod($this->valid, 'isModRewriteEnabled'));
 }
예제 #22
0
파일: MenuTest.php 프로젝트: ignaszak/cms
 public function testCreateMenuFromMenuItemsArray()
 {
     $menuString = MockTest::callMockMethod(self::$menu, 'createMenu', ['']);
     $this->assertNotEmpty($menuString);
     $this->assertTrue(is_string($menuString));
 }
예제 #23
0
 private function formatData(string $value, string $key) : string
 {
     return MockTest::callMockMethod('Ignaszak\\Exception\\Modules\\Variable', 'formatServerDataValue', [$value, $key]);
 }
예제 #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());
 }
예제 #25
0
 public function testValidLink()
 {
     $this->assertTrue(MockTest::callMockMethod($this->urlGenerator, 'validLink', ['/anyLink/with/replaced/token/', 'routName']));
 }
예제 #26
0
 private function httpMethod(string $route, string $current) : bool
 {
     $result = MockTest::callMockMethod($this->matcher, 'httpMethod', [$route, $current]);
     return $result;
 }
예제 #27
0
 public function testBegin()
 {
     MockTest::inject($this->_fileContent, 'offset', 10);
     MockTest::inject($this->_fileContent, 'line', 66);
     $this->assertEquals(56, MockTest::callMockMethod($this->_fileContent, 'getBegin'));
 }
예제 #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'));
 }
예제 #29
0
 private function getErrorTypeByNumber(int $errorType) : string
 {
     return MockTest::callMockMethod($this->_errorHandler, 'getErrorTypeByNumber', array($errorType));
 }
예제 #30
0
 public function testGetPatterns()
 {
     MockTest::inject($this->converter, 'routeArray', ['patterns' => ['pattern' => 'regex']]);
     $this->assertTrue(array_key_exists('@pattern', MockTest::callMockMethod($this->converter, 'getPatterns')));
 }