Пример #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
 /**
  * Expected to not reset properties when setParameters called with identical
  * parameters
  *
  * @covers ::setParameters
  * @depends testSetParameters
  */
 public function testSetParametersNoChange()
 {
     $parameters = ['baz' => 'bat', 'burz' => 'um'];
     Utility::setProperties(['parameters' => $parameters], $this->testObj);
     $this->testObj->expects($this->never())->method('resetProperties');
     $this->testObj->setParameters($parameters);
 }
Пример #3
0
 /**
  * @covers ::touchesData
  */
 public function testTouchesData()
 {
     $default = true;
     $this->assertEquals($default, $this->testObj->touchesData());
     $value = false;
     Utility::setProperties(['touchesData' => $value], $this->testObj);
     $this->assertEquals($value, $this->testObj->touchesData());
 }
 /**
  * Case when handler is not set, should not be possible but exceptions
  * must not ever leak from Initiate so should be covered anyway
  * 
  * @covers ::Initiate
  * @covers ::handlerFailure
  * @depends testInitiateExceptionRaised
  */
 public function testInitiateNoHandler()
 {
     Utility::setProperties(['handler' => null], $this->testObj);
     $e = new \Exception('test message');
     $this->handlerMock->expects($this->never())->method('Handle');
     $this->ioMock->expects($this->once())->method('toErrorLog')->With($this->isType('string'));
     $this->ioMock->expects($this->once())->method('toExit')->With($this->isType('string'));
     $this->testObj->Initiate($e);
 }
Пример #5
0
 /**
  * @covers ::returnView
  */
 public function testReturnView()
 {
     $content = 'foobar';
     $type = 'foo';
     $meta = ['foo' => 'bar'];
     $expected = ['content' => $content, 'type' => $type, 'meta' => $meta];
     $properties = ['viewContent' => $content, 'contentType' => $type, 'metaData' => $meta];
     Utility::setProperties($properties, $this->testObj);
     $this->assertEquals($expected, $this->testObj->returnView());
 }
Пример #6
0
 /**
  * Ensure empty fetch case is safe for existing data
  * 
  * @depends testFetchMetaDataEmptyFetch
  * @covers ::fetchMetaData
  */
 public function testFetchMetaDataEmptyFetchWithExisting()
 {
     $route = 'foobar';
     $data = null;
     $existing = ['lorem' => 'ipsum'];
     Utility::setProperties(['metaRoute' => $route], $this->testObj);
     $this->testObj->metaData = $existing;
     $this->serviceMock->expects($this->once())->method('getPage')->with($this->identicalTo($route))->willReturn($data);
     $this->testObj->fetchMetaData();
     $this->assertEquals($existing, $this->testObj->metaData);
 }
Пример #7
0
 protected function setUp()
 {
     $class = $this->testedClass;
     $configInterface = $class::INTERFACE_CONFIG;
     $this->configMock = $this->getMock($configInterface);
     $locatorInterface = $class::INTERFACE_LOCATOR;
     $this->locatorMock = $this->getMock($locatorInterface);
     $mockedMethods = ['getServerProp'];
     $this->testObj = $this->getMockBuilder($this->testedClass)->disableOriginalConstructor()->setMethods($mockedMethods)->getMock();
     $props = ['config' => $this->configMock, 'locator' => $this->locatorMock, 'instance' => $this->testObj];
     Utility::setProperties($props, $this->testObj);
 }
Пример #8
0
 protected function setUp()
 {
     $connectionClass = '\\stdClass';
     //can't mock \PDO directly
     $statementClass = '\\stdClass';
     //can't mock \PDOStatement directly
     $testedClass = '\\rakelley\\jhframe\\classes\\StatementAbstractor';
     $this->testObj = $this->getMockBuilder($testedClass)->disableOriginalConstructor()->setMethods(null)->getMock();
     $this->statementMock = $this->getMockBuilder($statementClass)->disableOriginalConstructor()->setMethods(['bindValue', 'execute', 'fetch', 'fetchAll'])->getMock();
     $this->connectionMock = $this->getMockBuilder($connectionClass)->disableOriginalConstructor()->setMethods(['prepare'])->getMock();
     $properties = ['connection' => $this->connectionMock, 'stmnt' => $this->statementMock];
     Utility::setProperties($properties, $this->testObj);
 }
Пример #9
0
 /**
  * @covers ::getContent
  * @dataProvider contentProvider
  * @depends testGetSuccess
  * @depends testGetError
  * @depends testGetMessage
  */
 public function testGetContent($properties, $expected)
 {
     if (isset($properties['content'])) {
         Utility::setProperties(['content' => $properties['content']], $this->testObj);
     }
     if (isset($properties['success'])) {
         $this->testObj->setSuccess($properties['success']);
     }
     if (isset($properties['error'])) {
         $this->testObj->setError($properties['error']);
     }
     if (isset($properties['message'])) {
         $this->testObj->setMessage($properties['message']);
     }
     $this->assertEquals($expected, $this->testObj->getContent());
 }
Пример #10
0
 /**
  * @covers ::matchRoute
  * @dataProvider badRouteProvider
  */
 public function testMatchRouteFailure($routes, $type, $route)
 {
     Utility::setProperties(['routes' => $routes], $this->testObj);
     $this->setExpectedException('\\UnexpectedValueException');
     $this->testObj->matchRoute($type, $route);
 }
Пример #11
0
 protected function setUpProperties(array $properties)
 {
     Utility::setProperties(['properties' => $properties], $this->testObj);
 }
Пример #12
0
 /**
  * @covers ::getResult
  */
 public function testGetResult()
 {
     $validated = ['foo' => 'bar', 'baz' => 'bat'];
     Utility::setProperties(['validated' => $validated], $this->testObj);
     $this->assertEquals($validated, $this->testObj->getResult());
 }
Пример #13
0
 protected function setUpStored(array $stored)
 {
     Utility::setProperties(['config' => $stored], $this->testObj);
 }
Пример #14
0
 /**
  * @covers ::Render
  * @covers ::handleType
  * @depends testRenderJson
  */
 public function testRenderWithAjax()
 {
     Utility::setProperties(['isAjax' => true], $this->testObj);
     $renderable = ['content' => 'lorem ipsum', 'type' => IRenderer::TYPE_PLAIN];
     $this->testRenderJson($renderable);
 }
Пример #15
0
 /**
  * @covers ::makeRelative
  */
 public function testMakeRelative()
 {
     $properties = ['directory' => '/foo/bar/baz/', 'relativePath' => 'baz/'];
     Utility::setProperties($properties, $this->testObj);
     $path = '/foo/bar/baz/bat.txt';
     $expected = 'baz/bat.txt';
     $this->assertEquals($expected, $this->testObj->makeRelative($path));
 }
Пример #16
0
 /**
  * @covers ::standardConstructor
  * @depends testConstructView
  */
 public function testStandardConstructorWithMessage()
 {
     $message = 'success message';
     $fields = ['footextarea' => ['type' => 'textarea', 'lorem' => 'ipsum']];
     $properties = ['attributes' => ['any', 'array'], 'data' => [], 'fields' => $fields, 'title' => null];
     Utility::setProperties($properties, $this->testObj);
     $this->builderMock->method('combineAttributes')->willReturn('attribute_string');
     $this->builderMock->method('constructTextarea')->willReturn('textarea_string');
     $this->builderMock->expects($this->once())->method('constructStatusBlock')->with($this->identicalTo($message))->willReturn('statusblock_string');
     $result = Utility::callMethod($this->testObj, 'standardConstructor', [$message]);
     $this->assertTrue(strlen($result) > 1);
 }