Browse Source

Assert TestApp\Model\Table\PostsTable instead of \Exception class

Ishan Vyas 5 years ago
parent
commit
e3c167c7f5
1 changed files with 6 additions and 8 deletions
  1. 6 8
      tests/TestCase/Utility/FileLogTest.php

+ 6 - 8
tests/TestCase/Utility/FileLogTest.php

@@ -2,6 +2,7 @@
 
 namespace Tools\Test\Utility;
 
+use Cake\ORM\TableRegistry;
 use Exception;
 use Shim\TestSuite\TestCase;
 use Tools\Utility\FileLog;
@@ -143,18 +144,15 @@ class FileLogTest extends TestCase {
 			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)
 		);