-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathFieldMigrationChangeTest.php
46 lines (36 loc) · 1.33 KB
/
FieldMigrationChangeTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Created by PhpStorm.
* User: alex
* Date: 23/03/19
* Time: 1:28 AM
*/
namespace CrestApps\CodeGenerator\Tests;
use CrestApps\CodeGenerator\Models\Field;
use CrestApps\CodeGenerator\Models\FieldMigrationChange;
use CrestApps\CodeGenerator\Models\ForeignConstraint;
class FieldMigrationChangeTest extends TestCase
{
public function testDetectFieldChangeWhenForeignConstraintAdded()
{
$fromField = new Field('transfer_id', 'migration');
$constraint = new ForeignConstraint('transfer_id', 'id', 'transfers');
$toField = new Field('transfer_id', 'migration');
$toField->setForeignConstraint($constraint);
$change = new FieldMigrationChange();
$change->fromField = $fromField;
$change->toField = $toField;
$this->assertTrue($change->hasChange());
}
public function testDetectFieldChangeWhenForeignConstraintRemoved()
{
$constraint = new ForeignConstraint('transfer_id', 'id', 'transfers');
$fromField = new Field('transfer_id', 'migration');
$fromField->setForeignConstraint($constraint);
$toField = new Field('transfer_id', 'migration');
$change = new FieldMigrationChange();
$change->fromField = $fromField;
$change->toField = $toField;
$this->assertTrue($change->hasChange());
}
}