Skip to content

Commit 62f7b66

Browse files
author
Andrey Helldar
committed
Updated tests
1 parent 592c68e commit 62f7b66

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed

tests/Commands/CreatorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public function testCreateAction()
1818
$this->assertFileDoesNotExist($path);
1919

2020
$this->artisan('make:migration:action', compact('name'))->run();
21-
$this->await();
2221

2322
$this->assertFileExists($path);
2423
}

tests/Commands/MakeTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public function testMakingFiles()
1717
$this->assertFileDoesNotExist($path);
1818

1919
$this->artisan('make:migration:action', compact('name'))->run();
20-
$this->await();
2120

2221
$this->assertFileExists($path);
2322

tests/Commands/StatusTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public function testStatusCommand()
2121

2222
$this->assertDatabaseCount($this->table, 0);
2323

24-
$this->artisan('migrate:actions:status')->expectsTable([], [])->run();
24+
if ($this->is6x()) {
25+
$this->artisan('migrate:actions:status')->run();
26+
} else {
27+
$this->artisan('migrate:actions:status')->expectsTable([], [])->run();
28+
}
2529

2630
$filename = date('Y_m_d_His') . '_status';
2731

tests/Concerns/AssertDatabase.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Tests\Concerns;
4+
5+
use Illuminate\Support\Facades\DB;
6+
7+
/** @mixin \Tests\TestCase */
8+
trait AssertDatabase
9+
{
10+
protected function assertDatabaseCount($table, int $count, $connection = null)
11+
{
12+
$actual = DB::connection($connection)->table($table)->count();
13+
14+
$this->assertEquals($count, $actual);
15+
}
16+
}

tests/Concerns/Laraveable.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Tests\Concerns;
4+
5+
use Illuminate\Foundation\Application;
6+
use Illuminate\Support\Str;
7+
8+
trait Laraveable
9+
{
10+
protected function is6x(): bool
11+
{
12+
return $this->majorVersion() === 6;
13+
}
14+
15+
protected function is7x(): bool
16+
{
17+
return $this->majorVersion() === 7;
18+
}
19+
20+
protected function is8x(): bool
21+
{
22+
return $this->majorVersion() === 8;
23+
}
24+
25+
protected function majorVersion(): int
26+
{
27+
return Str::before(Application::VERSION, '.');
28+
}
29+
}

tests/Concerns/Sleepable.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/TestCase.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77
use Illuminate\Support\Facades\DB;
88
use Orchestra\Testbench\TestCase as BaseTestCase;
99
use Tests\Concerns\Actionable;
10+
use Tests\Concerns\AssertDatabase;
1011
use Tests\Concerns\Database;
1112
use Tests\Concerns\Files;
13+
use Tests\Concerns\Laraveable;
1214
use Tests\Concerns\Settings;
13-
use Tests\Concerns\Sleepable;
1415

1516
abstract class TestCase extends BaseTestCase
1617
{
1718
use Actionable;
19+
use AssertDatabase;
1820
use Database;
1921
use Files;
22+
use Laraveable;
2023
use RefreshDatabase;
2124
use Settings;
22-
use Sleepable;
2325

2426
protected function setUp(): void
2527
{

0 commit comments

Comments
 (0)