@@ 122-151 (lines=30) @@ | ||
119 | $this->assertFileExists('build/a/c/c.txt'); |
|
120 | } |
|
121 | ||
122 | public function testRollbackAfterFailureViaACollectionBuilder() |
|
123 | { |
|
124 | // This is like the previous test, toRunMultipleTasksViaACollectionBuilder, |
|
125 | // except we force an error at the end, and confirm that the |
|
126 | // rollback function is called. |
|
127 | $collection = $this->collectionBuilder(); |
|
128 | $result = $collection->taskFilesystemStack() |
|
129 | ->mkdir('j') |
|
130 | ->touch('j/j.txt') |
|
131 | ->rollback( |
|
132 | $this->taskDeleteDir('j') |
|
133 | ) |
|
134 | ->taskFilesystemStack() |
|
135 | ->mkdir('j/k') |
|
136 | ->touch('j/k/k.txt') |
|
137 | ->taskFilesystemStack() |
|
138 | ->mkdir('j/k/m') |
|
139 | ->touch('j/k/m/m.txt') |
|
140 | ->taskCopyDir(['doesNotExist' => 'copied']) |
|
141 | ->run(); |
|
142 | ||
143 | $this->assertEquals(1, $result->getExitCode(), $result->getMessage()); |
|
144 | ||
145 | // All of the tasks created by the builder should be added |
|
146 | // to a collection, and `run()` should run them all. |
|
147 | $this->assertFileNotExists('q/q.txt'); |
|
148 | $this->assertFileNotExists('j/j.txt'); |
|
149 | $this->assertFileNotExists('j/k/k.txt'); |
|
150 | $this->assertFileNotExists('j/k/m/m.txt'); |
|
151 | } |
|
152 | ||
153 | public function testAbortRollbackOrCompletion() |
|
154 | { |
|
@@ 153-183 (lines=31) @@ | ||
150 | $this->assertFileNotExists('j/k/m/m.txt'); |
|
151 | } |
|
152 | ||
153 | public function testAbortRollbackOrCompletion() |
|
154 | { |
|
155 | // This is like the previous test, except we throw a ForcedException() |
|
156 | // inside the rollback to abort the rollback. |
|
157 | $collection = $this->collectionBuilder(); |
|
158 | $result = $collection->taskFilesystemStack() |
|
159 | ->mkdir('j') |
|
160 | ->touch('j/j.txt') |
|
161 | ->rollback( |
|
162 | $this->taskDeleteDir('j') |
|
163 | ) |
|
164 | ->rollbackCode(function () { |
|
165 | throw new AbortTasksException('Aborting rollback.'); |
|
166 | }) |
|
167 | ->taskFilesystemStack() |
|
168 | ->mkdir('j/k') |
|
169 | ->touch('j/k/k.txt') |
|
170 | ->taskFilesystemStack() |
|
171 | ->mkdir('j/k/m') |
|
172 | ->touch('j/k/m/m.txt') |
|
173 | ->taskCopyDir(['doesNotExist' => 'copied']) |
|
174 | ->run(); |
|
175 | ||
176 | $this->assertEquals(1, $result->getExitCode(), $result->getMessage()); |
|
177 | ||
178 | // All of the tasks created by the builder should be added |
|
179 | // to a collection, and `run()` should run them all. |
|
180 | $this->assertFileExists('j/j.txt'); |
|
181 | $this->assertFileExists('j/k/k.txt'); |
|
182 | $this->assertFileExists('j/k/m/m.txt'); |
|
183 | } |
|
184 | ||
185 | public function testRollbackAWorkingDir() |
|
186 | { |