Пример #1
0
 /**
  * @covers ::__construct
  * @depends testConstruct
  */
 public function testConstructFailure()
 {
     Utility::setProperties(['rootDir' => null], $this->testObj);
     $this->testObj->expects($this->once())->method('getRootConstant')->willReturn(null);
     $this->setExpectedException('\\RuntimeException');
     Utility::callConstructor($this->testObj);
 }
Пример #2
0
 /**
  * Test methods need to explictly call this method because we need to delay
  * testObj construction until after config has been set up
  */
 protected function setUpLogger($args = null)
 {
     $this->setUpConfig($args);
     $testedClass = '\\rakelley\\jhframe\\classes\\Logger';
     $mockedMethods = ['getConfig', 'getServerProp'];
     $this->testObj = $this->getMockBuilder($testedClass)->disableOriginalConstructor()->setMethods($mockedMethods)->getMock();
     $this->testObj->method('getConfig')->willReturn($this->configMock);
     Utility::callConstructor($this->testObj, [$this->systemMock]);
 }
Пример #3
0
 /**
  * Set up config store and call test object constructor.  null is a valid
  * value for any arg so need to use array_key_exists instead of isset
  * 
  * @param array $args Args to pass to configMock
  */
 protected function setUpWithConfig(array $args = array())
 {
     $appName = array_key_exists('appName', $args) ? $args['appName'] : 'anystring';
     $dir = array_key_exists('dir', $args) ? $args['dir'] : null;
     $lifetime = array_key_exists('lifetime', $args) ? $args['lifetime'] : null;
     $this->configMock->expects($this->at(0))->method('Get')->with($this->identicalTo('APP'), $this->identicalTo('name'))->willReturn($appName);
     $this->configMock->expects($this->at(1))->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('cache_dir'))->willReturn($dir);
     $this->configMock->expects($this->at(2))->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('cache_lifetime'))->willReturn($lifetime);
     Utility::callConstructor($this->testObj, [$this->fileSystemMock]);
 }
Пример #4
0
 protected function setUpInput($rules = null)
 {
     $configInterface = '\\rakelley\\jhframe\\interfaces\\services\\IConfig';
     $testedClass = '\\rakelley\\jhframe\\classes\\Input';
     $configMock = $this->getMock($configInterface);
     $configMock->method('Get')->with($this->identicalTo('APP'), $this->identicalTo('input_rules'))->willReturn($rules);
     $mockedMethods = ['getConfig'];
     $this->testObj = $this->getMockBuilder($testedClass)->disableOriginalConstructor()->setMethods($mockedMethods)->getMock();
     $this->testObj->method('getConfig')->willReturn($configMock);
     Utility::callConstructor($this->testObj, [$this->filterMock, $this->ioMock]);
 }
Пример #5
0
 protected function setUp()
 {
     $configInterface = '\\rakelley\\jhframe\\interfaces\\services\\IConfig';
     $systemInterface = '\\rakelley\\jhframe\\interfaces\\services\\IFileSystemAbstractor';
     $testedClass = '\\rakelley\\jhframe\\classes\\FlatView';
     $configMock = $this->getMock($configInterface);
     $configMock->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('root_dir'))->willReturn($this->rootDir);
     $this->systemMock = $this->getMock($systemInterface);
     $mockedMethods = ['getConfig'];
     $this->testObj = $this->getMockBuilder($testedClass)->disableOriginalConstructor()->setMethods($mockedMethods)->getMock();
     $this->testObj->method('getConfig')->willReturn($configMock);
     Utility::callConstructor($this->testObj, [$this->systemMock]);
 }
Пример #6
0
 /**
  * Set up config store and call test object constructor.  null is a valid
  * value for any arg so need to use array_key_exists instead of isset
  * 
  * @param array|null $args Args to pass to configMock
  */
 protected function setUpWithConfig(array $args = null)
 {
     $isAjax = array_key_exists('isAjax', $args) ? $args['isAjax'] : false;
     $envType = array_key_exists('envType', $args) ? $args['envType'] : 'production';
     $publicDir = array_key_exists('publicDir', $args) ? $args['publicDir'] : 'a string';
     $errorView = array_key_exists('errorView', $args) ? $args['errorView'] : 'a string';
     $logLevel = array_key_exists('logLevel', $args) ? $args['logLevel'] : null;
     $this->configMock->expects($this->at(0))->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('is_ajax'))->willReturn($isAjax);
     $this->configMock->expects($this->at(1))->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('type'))->willReturn($envType);
     $this->configMock->expects($this->at(2))->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('public_dir'))->willReturn($publicDir);
     $this->configMock->expects($this->at(3))->method('Get')->with($this->identicalTo('APP'), $this->identicalTo('error_view'))->willReturn($errorView);
     $this->configMock->expects($this->at(4))->method('Get')->with($this->identicalTo('APP'), $this->identicalTo('exception_log_level'))->willReturn($logLevel);
     Utility::callConstructor($this->testObj, [$this->containerMock, $this->fileMock, $this->ioMock]);
 }
Пример #7
0
 protected function setUpRouter($controllerTakesArg = false)
 {
     $configInterface = '\\rakelley\\jhframe\\interfaces\\services\\IConfig';
     $testedClass = '\\rakelley\\jhframe\\classes\\Router';
     $configMock = $this->getMock($configInterface);
     $configMock->expects($this->once())->method('Get')->with($this->identicalTo('APP'), $this->identicalTo('name'))->willReturn('example');
     $mockedMethods = ['getConfig', 'getLocator'];
     if ($controllerTakesArg) {
         $mockedMethods[] = 'methodTakesArg';
     }
     $this->testObj = $this->getMockBuilder($testedClass)->disableOriginalConstructor()->setMethods($mockedMethods)->getMock();
     $this->testObj->method('getConfig')->willReturn($configMock);
     $this->testObj->method('getLocator')->willReturn($this->locatorMock);
     if ($controllerTakesArg) {
         $this->testObj->method('methodTakesArg')->willReturn(true);
     }
     Utility::callConstructor($this->testObj);
 }
Пример #8
0
 protected function setUp()
 {
     $configInterface = '\\rakelley\\jhframe\\interfaces\\services\\IConfig';
     $locatorInterface = '\\rakelley\\jhframe\\interfaces\\services\\IServiceLocator';
     $ioInterface = '\\rakelley\\jhframe\\interfaces\\services\\IIo';
     $templateInterface = '\\rakelley\\jhframe\\interfaces\\ITemplate';
     $renderableInterface = '\\rakelley\\jhframe\\interfaces\\IRenderable';
     $testedClass = '\\rakelley\\jhframe\\classes\\Renderer';
     $configMock = $this->getMock($configInterface);
     $configMock->method('Get')->with($this->identicalTo('ENV'), $this->identicalTo('is_ajax'))->willReturn(false);
     $this->locatorMock = $this->getMock($locatorInterface);
     $this->ioMock = $this->getMock($ioInterface);
     $this->templateMock = $this->getMock($templateInterface);
     $this->renderableMock = $this->getMock($renderableInterface);
     $mockedMethods = ['getConfig', 'getLocator'];
     $this->testObj = $this->getMockBuilder($testedClass)->disableOriginalConstructor()->setMethods($mockedMethods)->getMock();
     $this->testObj->method('getConfig')->willReturn($configMock);
     $this->testObj->method('getLocator')->willReturn($this->locatorMock);
     Utility::callConstructor($this->testObj, [$this->ioMock]);
 }
Пример #9
0
 /**
  * @covers ::__construct
  *
  * setUp construction bypasses constructor because \PDO mock needs to have
  * mockable methods
  */
 public function testConstruct()
 {
     $pdoMock = new StatementAbstractorTestDummy();
     Utility::callConstructor($this->testObj, [$pdoMock]);
     $this->assertAttributeEquals($pdoMock, 'connection', $this->testObj);
 }
Пример #10
0
 protected function setUpWithConstructor()
 {
     Utility::setProperties(['fileSystem' => null, 'directory' => null], $this->testObj);
     Utility::callConstructor($this->testObj, [$this->systemMock]);
 }