PHP code example of ohffs / counts-database-queries-trait
1. Go to this page and download the library: Download ohffs/counts-database-queries-trait library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ohffs / counts-database-queries-trait example snippets
namespace Tests\Feature;
use Ohffs\CountsDatabaseQueries\CountsDatabaseQueries;
class MyAmazingTest extends TestCase
{
use CountsDatabaseQueries;
/** @test */
public function we_can_see_the_webpage()
{
$user = User::factory()->create();
$stuff = Stuff::factory()->count(3)->create();
// you'd usually want to start counting only after all your setup calls
$this->countDatabaseQueries();
$response = $this->actingAs($user)->get('/stuff');
$response->assertOk();
$response->assertSee('Stuff');
$this->assertQueryCountEquals(6);
$this->assertQueryCountBetween(5, 7);
$this->assertQueryCountGreaterThan(5);
$this->assertQueryCountLessThan(7);
dd($this->getDatabaseQueries());
}
}