1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* The MIT License |
5
|
|
|
* |
6
|
|
|
* Copyright 2014 ekow. |
7
|
|
|
* |
8
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
9
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
10
|
|
|
* in the Software without restriction, including without limitation the rights |
11
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
13
|
|
|
* furnished to do so, subject to the following conditions: |
14
|
|
|
* |
15
|
|
|
* The above copyright notice and this permission notice shall be included in |
16
|
|
|
* all copies or substantial portions of the Software. |
17
|
|
|
* |
18
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24
|
|
|
* THE SOFTWARE. |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace yentu\tests\cases; |
28
|
|
|
|
29
|
|
|
use org\bovigo\vfs\vfsStream; |
30
|
|
|
use yentu\commands\Migrate; |
31
|
|
|
|
32
|
|
|
class MigrateOptionsTest extends \yentu\tests\YentuTest { |
33
|
|
|
|
34
|
|
|
public function setUp() { |
35
|
|
|
$this->testDatabase = 'yentu_migration_test'; |
36
|
|
|
parent::setup(); |
37
|
|
|
$this->setupForMigration(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testMigration() { |
41
|
|
|
copy('tests/migrations/12345678901234_import.php', vfsStream::url('home/yentu/migrations/12345678901234_import.php')); |
42
|
|
|
|
43
|
|
|
$migrate = new Migrate($this->yentu, $this->getManipulatorFactory(), $this->io, $this->config); |
44
|
|
|
$migrate->run(array('no-foreign-keys' => true)); |
45
|
|
|
$this->assertEquals( |
46
|
|
|
file_get_contents("tests/streams/migrate_options_output_1.txt"), file_get_contents(vfsStream::url('home/output.txt')) |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
foreach ($this->fkeys as $fkey) { |
50
|
|
|
$this->assertForeignKeyDoesntExist($fkey); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
file_put_contents(vfsStream::url("home/output.txt"), ''); |
54
|
|
|
|
55
|
|
|
$migrate = new Migrate($this->yentu, $this->getManipulatorFactory(), $this->io, $this->config); |
56
|
|
|
$migrate->run(array('only-foreign-keys' => true)); |
57
|
|
|
$this->assertEquals( |
58
|
|
|
file_get_contents("tests/streams/migrate_options_output_2.txt"), file_get_contents(vfsStream::url('home/output.txt')) |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
foreach ($this->fkeys as $fkey) { |
62
|
|
|
$this->assertForeignKeyExists($fkey); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
private $fkeys = array( |
67
|
|
|
array("table" => "users", "name" => "users_branch_id_branches_branch_id_fk"), |
68
|
|
|
array("table" => "users", "name" => "users_department_id_departments_department_id_fk"), |
69
|
|
|
array("table" => "users", "name" => "users_role_id_fk"), |
70
|
|
|
array("table" => "temporary_roles", "name" => "temporary_rol_new_role_id_fk"), |
71
|
|
|
array("table" => "temporary_roles", "name" => "temporary_rol_orig_role_id_fk"), |
72
|
|
|
array("table" => "temporary_roles", "name" => "temporary_roles_user_id_fk"), |
73
|
|
|
array("table" => "suppliers", "name" => "suppliers_user_id_fk"), |
74
|
|
|
array("table" => "permissions", "name" => "permissios_role_id_fk"), |
75
|
|
|
array("table" => "notes", "name" => "notes_user_id_fk"), |
76
|
|
|
array("table" => "regions", "name" => "regions_country_id_fk"), |
77
|
|
|
array("table" => "note_attachments", "name" => "note_attachments_note_id_fkey"), |
78
|
|
|
array("table" => "clients", "name" => "clients_branch_id_fkey"), |
79
|
|
|
array("table" => "clients", "name" => "clients_city_id_fk"), |
80
|
|
|
array("table" => "clients", "name" => "clients_country_id_fk"), |
81
|
|
|
array("table" => "clients", "name" => "clients_id_type_id_fk"), |
82
|
|
|
array("table" => "clients", "name" => "clients_nationality_id_fk"), |
83
|
|
|
array("table" => "client_users", "name" => "client_users_main_client_id_fk"), |
84
|
|
|
array("table" => "client_joint_accounts", "name" => "client_joint_id_type_id_fk"), |
85
|
|
|
array("table" => "client_joint_accounts", "name" => "client_joint_main_client_id_fk"), |
86
|
|
|
array("table" => "cities", "name" => "cities_region_id_fk"), |
87
|
|
|
array("table" => "bank_branches", "name" => "branch_bank_id_fk"), |
88
|
|
|
array("table" => "api_keys", "name" => "api_keys_user_id_fkey") |
89
|
|
|
); |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|