|
|
@@ -56,13 +56,32 @@ class QueryLoggerTest extends TestCase
|
|
|
'className' => 'Array',
|
|
|
'scopes' => ['foo'],
|
|
|
]);
|
|
|
- $logger->log(LogLevel::DEBUG, (string)$query, compact('query'));
|
|
|
+ $logger->log(LogLevel::DEBUG, $query, compact('query'));
|
|
|
|
|
|
$this->assertCount(1, Log::engine('queryLoggerTest')->read());
|
|
|
$this->assertCount(0, Log::engine('queryLoggerTest2')->read());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Tests that passed Stringable also work.
|
|
|
+ */
|
|
|
+ public function testLogFunctionStringable(): void
|
|
|
+ {
|
|
|
+ $this->skipIf(version_compare(PHP_VERSION, '8.0', '<'), 'Stringable exists since 8.0');
|
|
|
+
|
|
|
+ $logger = new QueryLogger(['connection' => '']);
|
|
|
+ $stringable = new class implements \Stringable
|
|
|
+ {
|
|
|
+ public function __toString(): string
|
|
|
+ {
|
|
|
+ return 'FooBar';
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $logger->log(LogLevel::DEBUG, $stringable, ['query' => null]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests that the connection name is logged with the query.
|
|
|
*/
|
|
|
public function testLogConnection(): void
|