|
18 | 18 |
|
19 | 19 | namespace FastForward\DevTools\Tests\Composer; |
20 | 20 |
|
21 | | -use Composer\Package\RootPackageInterface; |
22 | | -use Composer\EventDispatcher\EventDispatcher; |
23 | 21 | use Composer\Composer; |
24 | 22 | use Composer\IO\IOInterface; |
25 | 23 | use Composer\Plugin\Capability\CommandProvider; |
26 | 24 | use Composer\Script\Event as ScriptEvent; |
| 25 | +use Composer\Util\Loop; |
| 26 | +use Composer\Util\ProcessExecutor; |
27 | 27 | use FastForward\DevTools\Composer\Capability\DevToolsCommandProvider; |
28 | 28 | use FastForward\DevTools\Composer\Plugin; |
29 | 29 | use PHPUnit\Framework\Attributes\CoversClass; |
@@ -125,62 +125,29 @@ public function activateWillDoNothing(): void |
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | #[Test] |
128 | | - public function onPostInstallWillInstallScripts(): void |
| 128 | + public function runSyncCommandWillExecuteDevToolsSync(): void |
129 | 129 | { |
130 | 130 | $event = $this->prophesize(ScriptEvent::class); |
131 | 131 |
|
132 | | - // Mock RootPackageInterface para getPackage() |
133 | | - $package = $this->prophesize(RootPackageInterface::class); |
134 | | - $package->getName() |
135 | | - ->willReturn('fast-forward/dev-tools'); |
136 | | - $this->composer->getPackage() |
137 | | - ->willReturn($package->reveal()); |
| 132 | + // Mock ProcessExecutor |
| 133 | + $processExecutor = $this->prophesize(ProcessExecutor::class); |
| 134 | + $processExecutor->execute('vendor/bin/dev-tools dev-tools:sync') |
| 135 | + ->shouldBeCalled(); |
138 | 136 |
|
139 | | - // Mock EventDispatcher |
140 | | - $eventDispatcher = $this->prophesize(EventDispatcher::class); |
141 | | - $eventDispatcher->dispatchScript('dev-tools:sync', true) |
142 | | - ->willReturn(0); |
143 | | - $this->composer->getEventDispatcher() |
144 | | - ->willReturn($eventDispatcher->reveal()); |
| 137 | + // Mock Loop |
| 138 | + $loop = $this->prophesize(Loop::class); |
| 139 | + $loop->getProcessExecutor() |
| 140 | + ->willReturn($processExecutor->reveal()); |
145 | 141 |
|
146 | | - $event->getComposer() |
147 | | - ->willReturn($this->composer->reveal()); |
148 | | - $event->getIO() |
149 | | - ->willReturn($this->io->reveal()); |
150 | | - |
151 | | - $this->plugin->onPostInstall($event->reveal()); |
152 | | - |
153 | | - self::assertTrue(true); // Evita teste risky |
154 | | - } |
155 | | - |
156 | | - /** |
157 | | - * @return void |
158 | | - */ |
159 | | - #[Test] |
160 | | - public function onPostUpdateWillInstallScripts(): void |
161 | | - { |
162 | | - $event = $this->prophesize(ScriptEvent::class); |
163 | | - |
164 | | - // Mock RootPackageInterface para getPackage() |
165 | | - $package = $this->prophesize(RootPackageInterface::class); |
166 | | - $package->getName() |
167 | | - ->willReturn('fast-forward/dev-tools'); |
168 | | - $this->composer->getPackage() |
169 | | - ->willReturn($package->reveal()); |
170 | | - |
171 | | - // Mock EventDispatcher |
172 | | - $eventDispatcher = $this->prophesize(EventDispatcher::class); |
173 | | - $eventDispatcher->dispatchScript('dev-tools:sync', true) |
174 | | - ->willReturn(0); |
175 | | - $this->composer->getEventDispatcher() |
176 | | - ->willReturn($eventDispatcher->reveal()); |
| 142 | + // Mock Composer |
| 143 | + $composer = $this->prophesize(Composer::class); |
| 144 | + $composer->getLoop() |
| 145 | + ->willReturn($loop->reveal()); |
177 | 146 |
|
178 | 147 | $event->getComposer() |
179 | | - ->willReturn($this->composer->reveal()); |
180 | | - $event->getIO() |
181 | | - ->willReturn($this->io->reveal()); |
| 148 | + ->willReturn($composer->reveal()); |
182 | 149 |
|
183 | | - $this->plugin->onPostUpdate($event->reveal()); |
| 150 | + $this->plugin->runSyncCommand($event->reveal()); |
184 | 151 |
|
185 | 152 | self::assertTrue(true); // Evita teste risky |
186 | 153 | } |
|
0 commit comments