Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaszak committed Mar 21, 2016
1 parent a5715b3 commit 29af018
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/Modules/DisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function testDisableLoadDisplay()
*/
public function testLoadLocation()
{
define('TEST_MODE', true);
if (!defined('TEST_MODE')) {
define('TEST_MODE', true);
}
$location = 'http://example.com';

$_conf = Conf::instance();
Expand Down
84 changes: 83 additions & 1 deletion tests/Modules/LogFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testLogDirIsNotWritable()
$this->assertFalse($this->_logFile->createLogFile());
}

public function testCreateLogISDisabled()
public function testCreateLogIsDisabled()
{
$this->dirChmod(0777);
MockTest::mockConf('createLogFile', false);
Expand All @@ -36,7 +36,89 @@ public function testCreateLogFile()
$this->assertTrue($this->_logFile->createLogFile());
}

public function testLoadLogDisplayWithoutBacktrace()
{
MockTest::injectStatic(
'Ignaszak\Exception\Controller\IController',
'errorArray',
[
0 => [
'type' => 'Warning',
'message' => 'anyMessage',
'file' => 'anyFile',
'line' => 1,
]
]
);
$result = MockTest::callMockMethod($this->_logFile, 'loadLogDisplay');
$this->assertEquals(
[
'errors' => <<<EOT
#1 [Warning]
anyMessage in anyFile on line 1
EOT
,
'errorsCount' => 1

],
$result
);
MockTest::injectStatic(
'Ignaszak\Exception\Controller\IController',
'errorArray',
[]
);
}

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 dirChmod($mode)
{
Expand Down

0 comments on commit 29af018

Please sign in to comment.