9 private static function getManager( $continue, $allModules, $generatedModules ) {
26 $this->assertSame(
false, $manager->isGeneratorDone() );
27 $this->assertSame( $allModules, $manager->getRunModules() );
28 $manager->addContinueParam( $allModules[0],
'm1continue', [ 1, 2 ] );
29 $manager->addContinueParam( $allModules[2],
'mlcontinue', 2 );
30 $manager->addGeneratorContinueParam(
$generator,
'gcontinue', 3 );
31 $this->assertSame( [ [
33 'm1continue' =>
'1|2',
34 'continue' =>
'||mock2',
35 ],
false ], $manager->getContinuation() );
37 'mock1' => [
'm1continue' =>
'1|2' ],
38 'mocklist' => [
'mlcontinue' => 2 ],
39 'generator' => [
'gcontinue' => 3 ],
40 ], $manager->getRawContinuation() );
43 $manager->setContinuationIntoResult(
$result );
46 'm1continue' =>
'1|2',
47 'continue' =>
'||mock2',
48 ],
$result->getResultData(
'continue' ) );
49 $this->assertSame(
null,
$result->getResultData(
'batchcomplete' ) );
52 $this->assertSame(
false, $manager->isGeneratorDone() );
53 $this->assertSame( $allModules, $manager->getRunModules() );
54 $manager->addContinueParam( $allModules[0],
'm1continue', [ 1, 2 ] );
55 $manager->addGeneratorContinueParam(
$generator,
'gcontinue', [ 3, 4 ] );
56 $this->assertSame( [ [
57 'm1continue' =>
'1|2',
58 'continue' =>
'||mock2|mocklist',
59 ],
false ], $manager->getContinuation() );
61 'mock1' => [
'm1continue' =>
'1|2' ],
62 'generator' => [
'gcontinue' =>
'3|4' ],
63 ], $manager->getRawContinuation() );
66 $this->assertSame(
false, $manager->isGeneratorDone() );
67 $this->assertSame( $allModules, $manager->getRunModules() );
68 $manager->addContinueParam( $allModules[2],
'mlcontinue', 2 );
69 $manager->addGeneratorContinueParam(
$generator,
'gcontinue', 3 );
70 $this->assertSame( [ [
73 'continue' =>
'gcontinue||',
74 ],
true ], $manager->getContinuation() );
76 'mocklist' => [
'mlcontinue' => 2 ],
77 'generator' => [
'gcontinue' => 3 ],
78 ], $manager->getRawContinuation() );
81 $manager->setContinuationIntoResult(
$result );
85 'continue' =>
'gcontinue||',
86 ],
$result->getResultData(
'continue' ) );
87 $this->assertSame(
true,
$result->getResultData(
'batchcomplete' ) );
90 $this->assertSame(
false, $manager->isGeneratorDone() );
91 $this->assertSame( $allModules, $manager->getRunModules() );
92 $manager->addGeneratorContinueParam(
$generator,
'gcontinue', 3 );
93 $this->assertSame( [ [
95 'continue' =>
'gcontinue||mocklist',
96 ],
true ], $manager->getContinuation() );
98 'generator' => [
'gcontinue' => 3 ],
99 ], $manager->getRawContinuation() );
102 $this->assertSame(
false, $manager->isGeneratorDone() );
103 $this->assertSame( $allModules, $manager->getRunModules() );
104 $manager->addContinueParam( $allModules[0],
'm1continue', [ 1, 2 ] );
105 $manager->addContinueParam( $allModules[2],
'mlcontinue', 2 );
106 $this->assertSame( [ [
108 'm1continue' =>
'1|2',
109 'continue' =>
'||mock2',
110 ],
false ], $manager->getContinuation() );
112 'mock1' => [
'm1continue' =>
'1|2' ],
113 'mocklist' => [
'mlcontinue' => 2 ],
114 ], $manager->getRawContinuation() );
117 $this->assertSame(
false, $manager->isGeneratorDone() );
118 $this->assertSame( $allModules, $manager->getRunModules() );
119 $manager->addContinueParam( $allModules[0],
'm1continue', [ 1, 2 ] );
120 $this->assertSame( [ [
121 'm1continue' =>
'1|2',
122 'continue' =>
'||mock2|mocklist',
123 ],
false ], $manager->getContinuation() );
125 'mock1' => [
'm1continue' =>
'1|2' ],
126 ], $manager->getRawContinuation() );
129 $this->assertSame(
false, $manager->isGeneratorDone() );
130 $this->assertSame( $allModules, $manager->getRunModules() );
131 $manager->addContinueParam( $allModules[2],
'mlcontinue', 2 );
132 $this->assertSame( [ [
134 'continue' =>
'-||mock1|mock2',
135 ],
true ], $manager->getContinuation() );
137 'mocklist' => [
'mlcontinue' => 2 ],
138 ], $manager->getRawContinuation() );
141 $this->assertSame(
false, $manager->isGeneratorDone() );
142 $this->assertSame( $allModules, $manager->getRunModules() );
143 $this->assertSame( [ [],
true ], $manager->getContinuation() );
144 $this->assertSame( [], $manager->getRawContinuation() );
146 $manager =
self::getManager(
'||mock2', $allModules, [
'mock1',
'mock2' ] );
147 $this->assertSame(
false, $manager->isGeneratorDone() );
149 array_values( array_diff_key( $allModules, [ 1 => 1 ] ) ),
150 $manager->getRunModules()
154 $this->assertSame(
true, $manager->isGeneratorDone() );
156 array_values( array_diff_key( $allModules, [ 0 => 0, 1 => 1 ] ) ),
157 $manager->getRunModules()
162 $this->fail(
'Expected exception not thrown' );
171 array_slice( $allModules, 0, 2 ),
175 $manager->addContinueParam( $allModules[1],
'm2continue', 1 );
176 $this->fail(
'Expected exception not thrown' );
177 }
catch ( UnexpectedValueException $ex ) {
179 'Module \'mock2\' was not supposed to have been executed, ' .
180 'but it was executed anyway',
186 $manager->addContinueParam( $allModules[2],
'mlcontinue', 1 );
187 $this->fail(
'Expected exception not thrown' );
188 }
catch ( UnexpectedValueException $ex ) {
190 'Module \'mocklist\' called ApiContinuationManager::addContinueParam ' .
191 'but was not passed to ApiContinuationManager::__construct',