@@ 83-112 (lines=30) @@ | ||
80 | $I->seeFileFound('build/a/c/c.txt'); |
|
81 | } |
|
82 | ||
83 | public function toRollbackAfterFailureViaACollectionBuilder(CliGuy $I) |
|
84 | { |
|
85 | // This is like the previous test, toRunMultipleTasksViaACollectionBuilder, |
|
86 | // except we force an error at the end, and confirm that the |
|
87 | // rollback function is called. |
|
88 | $collection = $I->collectionBuilder(); |
|
89 | $result = $collection->taskFilesystemStack() |
|
90 | ->mkdir('j') |
|
91 | ->touch('j/j.txt') |
|
92 | ->rollback( |
|
93 | $I->taskDeleteDir('j') |
|
94 | ) |
|
95 | ->taskFilesystemStack() |
|
96 | ->mkdir('j/k') |
|
97 | ->touch('j/k/k.txt') |
|
98 | ->taskFilesystemStack() |
|
99 | ->mkdir('j/k/m') |
|
100 | ->touch('j/k/m/m.txt') |
|
101 | ->taskCopyDir(['doesNotExist' => 'copied']) |
|
102 | ->run(); |
|
103 | ||
104 | $I->assertEquals(1, $result->getExitCode(), $result->getMessage()); |
|
105 | ||
106 | // All of the tasks created by the builder should be added |
|
107 | // to a collection, and `run()` should run them all. |
|
108 | $I->dontSeeFileFound('q/q.txt'); |
|
109 | $I->dontSeeFileFound('j/j.txt'); |
|
110 | $I->dontSeeFileFound('j/k/k.txt'); |
|
111 | $I->dontSeeFileFound('j/k/m/m.txt'); |
|
112 | } |
|
113 | ||
114 | public function toAbortRollbackOrCompletion(CliGuy $I) |
|
115 | { |
|
@@ 114-144 (lines=31) @@ | ||
111 | $I->dontSeeFileFound('j/k/m/m.txt'); |
|
112 | } |
|
113 | ||
114 | public function toAbortRollbackOrCompletion(CliGuy $I) |
|
115 | { |
|
116 | // This is like the previous test, except we throw a ForcedException() |
|
117 | // inside the rollback to abort the rollback. |
|
118 | $collection = $I->collectionBuilder(); |
|
119 | $result = $collection->taskFilesystemStack() |
|
120 | ->mkdir('j') |
|
121 | ->touch('j/j.txt') |
|
122 | ->rollback( |
|
123 | $I->taskDeleteDir('j') |
|
124 | ) |
|
125 | ->rollbackCode(function () { |
|
126 | throw new AbortTasksException('Aborting rollback.'); |
|
127 | }) |
|
128 | ->taskFilesystemStack() |
|
129 | ->mkdir('j/k') |
|
130 | ->touch('j/k/k.txt') |
|
131 | ->taskFilesystemStack() |
|
132 | ->mkdir('j/k/m') |
|
133 | ->touch('j/k/m/m.txt') |
|
134 | ->taskCopyDir(['doesNotExist' => 'copied']) |
|
135 | ->run(); |
|
136 | ||
137 | $I->assertEquals(1, $result->getExitCode(), $result->getMessage()); |
|
138 | ||
139 | // All of the tasks created by the builder should be added |
|
140 | // to a collection, and `run()` should run them all. |
|
141 | $I->seeFileFound('j/j.txt'); |
|
142 | $I->seeFileFound('j/k/k.txt'); |
|
143 | $I->seeFileFound('j/k/m/m.txt'); |
|
144 | } |
|
145 | ||
146 | public function toRollbackAWorkingDir(CliGuy $I) |
|
147 | { |