Skip to content

Commit

Permalink
Assert TestApp\Model\Table\PostsTable instead of \Exception class
Browse files Browse the repository at this point in the history
  • Loading branch information
ishan-biztech committed Jun 26, 2020
1 parent 5ef2d1c commit e3c167c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/TestCase/Utility/FileLogTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Tools\Test\Utility;

use Cake\ORM\TableRegistry;
use Exception;
use Shim\TestSuite\TestCase;
use Tools\Utility\FileLog;
Expand Down Expand Up @@ -143,18 +144,15 @@ public function testLogsObject(): void {
unlink(static::TEST_FILEPATH_OBJECT);
}

try {
throw new Exception('Test', 1);
} catch (Exception $exception) {
// Do nothing
}

$result = FileLog::write($exception, static::TEST_FILENAME_OBJECT);
$result = FileLog::write(
TableRegistry::getTableLocator()->get('Posts'),
static::TEST_FILENAME_OBJECT
);

$this->assertTrue($result);
$this->assertFileExists(static::TEST_FILEPATH_OBJECT);
$this->assertRegExp(
'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: Exception Object/',
'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: TestApp.Model.Table.PostsTable Object/',
file_get_contents(static::TEST_FILEPATH_OBJECT)
);

Expand Down

0 comments on commit e3c167c

Please sign in to comment.