Skip to content

Commit 3561553

Browse files
committed
Update tests
1 parent a886799 commit 3561553

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

tests/BootstrapperTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use Guanguans\LaravelSoar\Bootstrapper;
1414
use Illuminate\Support\Collection;
15-
use Illuminate\Support\Str;
1615
use Nyholm\NSA;
1716

1817
class BootstrapperTest extends TestCase
@@ -42,6 +41,7 @@ public function testIsEnabled()
4241
public function testGetScores()
4342
{
4443
$this->assertInstanceOf(Collection::class, $scores = $this->bootstrapper->getScores());
44+
$scores->dump();
4545
$this->assertTrue($scores->isNotEmpty());
4646

4747
$scores->each(function ($score) {
@@ -51,10 +51,7 @@ public function testGetScores()
5151
$this->assertArrayHasKey('Explain', $score);
5252
$this->assertArrayHasKey('Backtraces', $score);
5353
$this->assertArrayHasKey('Basic', $score);
54-
55-
Str::startsWith($score['Basic']['Sample'], ['create', 'CREATE', 'insert', 'INSERT'])
56-
? $this->assertGreaterThanOrEqual(0, $score['Basic']['Score'])
57-
: $this->assertGreaterThan(0, $score['Basic']['Score']);
54+
$this->assertGreaterThanOrEqual(0, $score['Basic']['Score']);
5855
});
5956
}
6057

tests/FeatureTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testJsonOutput()
2828
{
2929
$response = $this->get('/json');
3030

31-
$this->assertJson($response->getContent());
31+
$this->assertJson($json = $response->getContent());
3232
$response->assertSee('soar_scores');
3333
$response->assertSee('Summary');
3434
$response->assertSee('HeuristicRules');

tests/Seeder/TestSeeder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,23 @@
1111
namespace Tests\Seeder;
1212

1313
use Illuminate\Database\Seeder;
14+
use Illuminate\Support\Str;
1415
use Tests\Models\User;
1516

1617
class TestSeeder extends Seeder
1718
{
1819
public function run()
1920
{
2021
factory(User::class, 5)->create();
22+
23+
User::query()->where('id', 1)->delete();
24+
25+
User::query()->where('id', 2)->update([
26+
'email_verified_at' => now(),
27+
'password' => Str::random(32),
28+
'remember_token' => Str::random(10),
29+
]);
30+
31+
User::query()->where('name', 'soar')->groupBy('name')->orderBy('name')->first();
2132
}
2233
}

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ protected function setUp(): void
2626
$this->setUpDatabase();
2727
$this->withFactories(__DIR__.'/Factories/');
2828
$this->seed(TestSeeder::class);
29+
$this->setUpApplicationRoutes();
2930
}
3031

3132
protected function getPackageProviders($app)
@@ -42,7 +43,7 @@ protected function getEnvironmentSetUp($app)
4243
$app['config']->set('soar.output', [
4344
\Guanguans\LaravelSoar\Outputs\ClockworkOutput::class,
4445
\Guanguans\LaravelSoar\Outputs\ConsoleOutput::class,
45-
\Guanguans\LaravelSoar\Outputs\DumpOutput::class => ['exit' => false],
46+
// \Guanguans\LaravelSoar\Outputs\DumpOutput::class => ['exit' => false],
4647
\Guanguans\LaravelSoar\Outputs\JsonOutput::class,
4748
\Guanguans\LaravelSoar\Outputs\LogOutput::class => ['channel' => 'stack'],
4849
\Guanguans\LaravelSoar\Outputs\DebugBarOutput::class,

0 commit comments

Comments
 (0)