Conceptually, you need to download all your queries using the PHP module code coverage tools.
This can be done directly with phpunit libraries or with xdebug coverage tools (which use phpunit).
From this example that I discovered, you can run coverage tools based on several _GET parameters passed using the Dusk test.
public function testBasicExample() { $this->browse(function (Browser $browser) { $browser->visit(route('test', [ 'test_name' => 'testBasicExample', 'coverage_dir' => '/app/Http' ]))->assertSee('test'); }); }
the code that does the work consists of two parts 1. Start compiling based on the parameters:
$test_name = $_GET['test_name']; require __DIR__ . '/../vendor/autoload.php'; $current_dir = __DIR__; $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage; $filter = $coverage->filter(); $filter->addDirectoryToWhitelist( $current_dir . '/..' . ((isset($_GET['coverage_dir']) && $_GET['coverage_dir']) ? $_GET['coverage_dir'] : '/app') ); $coverage->start($test_name);
And 2 finish the collection and conclusion:
function end_coverage() { global $test_name; global $coverage; global $filter; global $current_dir; $coverageName = $current_dir . '/coverages/coverage-' . $test_name . '-' . microtime(true); try { $coverage->stop(); $writer = new \SebastianBergmann\CodeCoverage\Report\Html\Facade; $writer->process($coverage, $current_dir . '/../public/report/' . $test_name); $writer = new SebastianBergmann\CodeCoverage\Report\PHP(); } catch (Exception $ex) { file_put_contents($coverageName . '.ex', $ex); } }
The final collection is called using a little tricky trick when the coverage_dumper class has only a destructor, which is called automatically when php terminates the process.
The code itself may tidy up the output paths and variables, but, based on the concept, it should work.
source share