and talents, as well as further developing them together." ACTION "We don't default to blindly following the rules. We encourage everyone to give feedback and show initiative at any time."
$numSqlQueries = \count($this->sqlQueryEvents); if ($expectedCount === $numSqlQueries) { $this->sqlCounterReset(); return; } $msg .= sprintf("Expected number of SQL statements of %d does not match the actual value of %d\nQueries:\n\n%s\n", $expectedCount, $numSqlQueries, implode("\n", array_map( function (QueryExecuted $query) { return sprintf('[%s] %s', $query->connectionName, $query->sql ); }, $this->sqlQueryEvents ) ) ); $this->assertSame($expectedCount, $numSqlQueries, $msg); }
$expectedQueries = trim($expectedQueries); $actualQueries = trim( implode("\n", array_map( function (QueryExecuted $query): string { // Replace any numeric literals with "fake" bind // placeholders. The framework recently optimized // whereIn queries to contain all-only integer // literals directly, which means it includes // IDs which may change during multiple test // runs, which we now manually need to normalize return preg_replace( [ // Covers integers in `WHERE IN ()` '/\d+(,|\))/', // Covers simple `WHERE x =` '/= \d+/', ], [ '?$1', '= ?', ], $query->sql) . ';'; }, $this->sqlQueryEvents ) ) ); $this->sqlCounterReset(); if (!$msg) { $msg = 'SQL queries mismatch'; } $this->assertSame($expectedQueries, $actualQueries, $msg); }