Skip to content

Commit a19b5d9

Browse files
author
Andrey Helldar
committed
Tests in process
1 parent 83f1030 commit a19b5d9

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"require-dev": {
2525
"mockery/mockery": "^1.3.1",
2626
"orchestra/testbench": "^4.0|^5.0|^6.0",
27-
"phpunit/phpunit": "^8.0|^9.0"
27+
"phpunit/phpunit": "^8.0|^9.0",
28+
"ramsey/uuid": "^3.7|^4.0"
2829
},
2930
"autoload": {
3031
"psr-4": {

tests/Commands/MigrateTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ public function testMigrationCommand()
2222
$this->assertDatabaseHasLike($this->table, 'migration', 'test_migration');
2323
}
2424

25+
public function testEveryTimeExecution()
26+
{
27+
$table = 'every_time';
28+
29+
$this->artisan('migrate:actions:install')->run();
30+
$this->artisan('migrate')->run();
31+
32+
$this->assertDatabaseCount($table, 0);
33+
$this->artisan('migrate:actions')->run();
34+
35+
$this->assertDatabaseCount($table, 1);
36+
$this->artisan('migrate:actions')->run();
37+
38+
$this->assertDatabaseCount($table, 2);
39+
}
40+
2541
public function testMigrationNotFound()
2642
{
2743
$this->assertDatabaseDoesntTable($this->table);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Helldar\LaravelActions\Support\Actionable;
4+
use Illuminate\Support\Facades\DB;
5+
use Ramsey\Uuid\Uuid;
6+
7+
final class EveryTime extends Actionable
8+
{
9+
protected $once = false;
10+
11+
public function up(): void
12+
{
13+
$this->table()->insert([
14+
'value' => Uuid::uuid4(),
15+
]);
16+
}
17+
18+
public function down(): void
19+
{
20+
// nothing
21+
}
22+
23+
protected function table()
24+
{
25+
return DB::table('every_time');
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
final class CreateEveryTimeTable extends Migration
8+
{
9+
public function up()
10+
{
11+
Schema::create('every_time', function (Blueprint $table) {
12+
$table->uuid('value');
13+
});
14+
}
15+
16+
public function down()
17+
{
18+
Schema::dropIfExists('every_time');
19+
}
20+
}

0 commit comments

Comments
 (0)