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 ntentan\config\Config; |
30
|
|
|
use yentu\commands\Init; |
31
|
|
|
use yentu\commands\Rollback; |
32
|
|
|
|
33
|
|
|
class RollbackTest extends \yentu\tests\YentuTest { |
34
|
|
|
|
35
|
|
|
public function setUp() { |
36
|
|
|
$this->testDatabase = 'yentu_rollback_test'; |
37
|
|
|
parent::setup(); |
38
|
|
|
$this->createDb($GLOBALS['DB_NAME']); |
39
|
|
|
$this->initDb($GLOBALS['DB_FULL_DSN'], file_get_contents("tests/sql/{$GLOBALS['DRIVER']}/pre_rollback.sql")); |
40
|
|
|
$this->connect($GLOBALS['DB_FULL_DSN']); |
41
|
|
|
$this->setupStreams(); |
42
|
|
|
$init = new Init($this->yentu, $this->getManipulatorFactory(), $this->io, $this->config); |
43
|
|
|
$init->createConfigFile( |
44
|
|
|
array( |
45
|
|
|
'driver' => $GLOBALS['DRIVER'], |
46
|
|
|
'host' => $GLOBALS['DB_HOST'], |
47
|
|
|
'dbname' => $GLOBALS["DB_NAME"], |
48
|
|
|
'user' => $GLOBALS['DB_USER'], |
49
|
|
|
'password' => $GLOBALS['DB_PASSWORD'], |
50
|
|
|
'file' => $GLOBALS['DB_FILE'] |
51
|
|
|
) |
52
|
|
|
); |
53
|
|
|
$this->config->readPath($this->yentu->getPath('config/default.conf.php')); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testRollback() { |
57
|
|
|
foreach ($this->tables as $table) { |
58
|
|
|
$this->assertTableExists($table); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$rollback = new Rollback($this->yentu, $this->getManipulatorFactory(), $this->io); |
62
|
|
|
$rollback->run(array()); |
63
|
|
|
|
64
|
|
|
foreach ($this->tables as $table) { |
65
|
|
|
if ($table == 'yentu_history') |
66
|
|
|
continue; |
67
|
|
|
$this->assertTableDoesntExist($table); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
private $tables = array( |
72
|
|
|
'api_keys', |
73
|
|
|
'audit_trail', |
74
|
|
|
'audit_trail_data', |
75
|
|
|
'bank_branches', |
76
|
|
|
'banks', |
77
|
|
|
'binary_objects', |
78
|
|
|
'branches', |
79
|
|
|
'cheque_formats', |
80
|
|
|
'cities', |
81
|
|
|
'client_joint_accounts', |
82
|
|
|
'clients', |
83
|
|
|
'client_users', |
84
|
|
|
'configurations', |
85
|
|
|
'countries', |
86
|
|
|
'departments', |
87
|
|
|
'holidays', |
88
|
|
|
'identification_types', |
89
|
|
|
'locations', |
90
|
|
|
'note_attachments', |
91
|
|
|
'notes', |
92
|
|
|
'notifications', |
93
|
|
|
'permissions', |
94
|
|
|
'regions', |
95
|
|
|
'relationships', |
96
|
|
|
'roles', |
97
|
|
|
'suppliers', |
98
|
|
|
'temporary_roles', |
99
|
|
|
'users', |
100
|
|
|
'yentu_history' |
101
|
|
|
); |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|