1414
1515use function array_merge ;
1616use function assert ;
17+ use function copy ;
1718use function realpath ;
1819use function sprintf ;
1920
2021class CliContext implements Context
2122{
2223 private const PHP_BINARY = 'php ' ;
24+ private const PIE_BINARY = '/usr/local/bin/pie ' ;
25+ private const PIE_BINARY_BACKUP = '/usr/local/bin/pie.original ' ;
2326 private string |null $ output = null ;
2427 private string |null $ errorOutput = null ;
2528 private int |null $ exitCode = null ;
@@ -44,7 +47,7 @@ public function iRunACommandToDownloadSpecificVersionOfAnExtension(string $versi
4447 /** @param list<non-empty-string> $command */
4548 public function runPieCommand (array $ command ): void
4649 {
47- $ pieCommand = array_merge ([self ::PHP_BINARY , ...$ this ->phpArguments , ' bin/pie ' ], $ command );
50+ $ pieCommand = array_merge ([self ::PHP_BINARY , ...$ this ->phpArguments , self :: PIE_BINARY ], $ command );
4851
4952 if ($ this ->workingDirectory !== null ) {
5053 $ pieCommand [] = '--working-dir ' ;
@@ -374,4 +377,26 @@ public function iRunACommandToInstallTheExtension(): void
374377 $ this ->thePackage = 'asgrim/example-pie-extension ' ;
375378 $ this ->runPieCommand (['install ' ]);
376379 }
380+
381+ #[Given('I have an old version of PIE ' )]
382+ public function iHaveAnOldVersionOfPIE (): void
383+ {
384+ // noop
385+ }
386+
387+ #[When('I update PIE to the latest version ' )]
388+ public function iUpdatePIEToTheLatestNightlyVersion (): void
389+ {
390+ $ this ->runPieCommand (['self-update ' , '--nightly ' , '-v ' ]);
391+
392+ copy (self ::PIE_BINARY_BACKUP , self ::PIE_BINARY );
393+ }
394+
395+ #[Then('I should see I have been updated to the latest version ' )]
396+ public function iShouldSeeIHaveBeenUpdatedToTheLatestVersion (): void
397+ {
398+ $ this ->assertCommandSuccessful ();
399+ Assert::contains ($ this ->output , '✅ Verified the new PIE version ' );
400+ Assert::contains ($ this ->output , '✅ PIE has been upgraded to nightly ' );
401+ }
377402}
0 commit comments