|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yawik\Migration\Tests\Handler; |
|
6
|
|
|
|
|
7
|
|
|
use CoreTestUtils\TestCase\FunctionalTestCase; |
|
|
|
|
|
|
8
|
|
|
use InvalidArgumentException; |
|
9
|
|
|
use Yawik\Migration\Handler\MigrationHandler; |
|
10
|
|
|
use Yawik\Migration\Tests\TestMigrator; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @covers \Yawik\Migration\Handler\MigrationHandler |
|
14
|
|
|
*/ |
|
15
|
|
|
class MigrationHandlerTest extends FunctionalTestCase |
|
16
|
|
|
{ |
|
17
|
|
|
public function setUp(): void |
|
18
|
|
|
{ |
|
19
|
|
|
parent::setUp(); |
|
20
|
|
|
$handler = $this->getHandler(); |
|
21
|
|
|
$ob = $handler->findOrCreate(new TestMigrator(), false); |
|
22
|
|
|
$dm = $this->getDoctrine(); |
|
23
|
|
|
|
|
24
|
|
|
if(!is_null($ob)){ |
|
25
|
|
|
$dm->remove($ob); |
|
26
|
|
|
$dm->flush(); |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return MigrationHandler |
|
32
|
|
|
*/ |
|
33
|
|
|
private function getHandler() |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->getService(MigrationHandler::class); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
private function create($className = TestMigrator::class) |
|
39
|
|
|
{ |
|
40
|
|
|
$handler = $this->getHandler(); |
|
41
|
|
|
$migrator = new $className(); |
|
42
|
|
|
|
|
43
|
|
|
return $handler->findOrCreate($migrator, true); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testFindOrCreate() |
|
47
|
|
|
{ |
|
48
|
|
|
$ob = $this->getHandler()->findOrCreate(new TestMigrator(), true); |
|
49
|
|
|
$this->assertNotNull($ob); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testCreate() |
|
53
|
|
|
{ |
|
54
|
|
|
$ob = $this->create(); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertNotNull($ob); |
|
57
|
|
|
$this->assertNotNull($ob->getId()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testMigrated() |
|
61
|
|
|
{ |
|
62
|
|
|
$ob = $this->create(); |
|
63
|
|
|
$handler = $this->getHandler(); |
|
64
|
|
|
|
|
65
|
|
|
$this->assertNull($ob->getMigratedAt()); |
|
66
|
|
|
$this->assertFalse($ob->isMigrated()); |
|
67
|
|
|
$handler->migrated(new TestMigrator()); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertTrue($ob->isMigrated()); |
|
70
|
|
|
$this->assertNotNull($ob->getMigratedAt()); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function testMigratedThrowsException() |
|
74
|
|
|
{ |
|
75
|
|
|
$this->expectException(InvalidArgumentException::class); |
|
76
|
|
|
$handler = $this->getHandler(); |
|
77
|
|
|
$handler->migrated(new TestMigrator()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths