@@ -64,8 +64,9 @@ protected function setUp(): void
6464
6565 $ this ->originalComposerEnv = (string ) getenv ('COMPOSER ' );
6666 $ this ->tempComposerFile = tempnam (sys_get_temp_dir (), 'composer_test ' );
67- file_put_contents ($ this ->tempComposerFile , json_encode (['name ' => 'test/package ' , 'scripts ' => (object ) []]));
68-
67+ // O nome do pacote precisa ser fast-forward/dev-tools para que o método installScripts execute a lógica
68+ file_put_contents ($ this ->tempComposerFile , json_encode (['name ' => 'fast-forward/dev-tools ' , 'scripts ' => (object ) []]));
69+
6970 putenv ("COMPOSER= {$ this ->tempComposerFile }" );
7071 $ _ENV ['COMPOSER ' ] = $ this ->tempComposerFile ;
7172 $ _SERVER ['COMPOSER ' ] = $ this ->tempComposerFile ;
@@ -115,6 +116,11 @@ public function onPostPackageInstallWillInstallScripts(): void
115116 {
116117 $ event = $ this ->prophesize (PackageEvent::class);
117118
119+ // Mock RootPackageInterface para getPackage()
120+ $ package = $ this ->prophesize (\Composer \Package \RootPackageInterface::class);
121+ $ package ->getName ()->willReturn ('fast-forward/dev-tools ' );
122+ $ this ->composer ->getPackage ()->willReturn ($ package ->reveal ());
123+
118124 $ event ->getComposer ()
119125 ->willReturn ($ this ->composer ->reveal ());
120126 $ event ->getIO ()
@@ -127,8 +133,8 @@ public function onPostPackageInstallWillInstallScripts(): void
127133
128134 $ data = json_decode (file_get_contents ($ this ->tempComposerFile ), true );
129135 self ::assertArrayHasKey ('scripts ' , $ data );
130- self ::assertSame ('./bin/ dev-tools ' , $ data ['scripts ' ]['dev-tools ' ]);
131- self ::assertSame ('./bin/ dev-tools --fix ' , $ data ['scripts ' ]['dev-tools:fix ' ]);
136+ self ::assertSame ('dev-tools ' , $ data ['scripts ' ]['dev-tools ' ]);
137+ self ::assertSame ('dev-tools --fix ' , $ data ['scripts ' ]['dev-tools:fix ' ]);
132138 }
133139
134140 /**
@@ -139,6 +145,11 @@ public function onPostPackageUpdateWillInstallScripts(): void
139145 {
140146 $ event = $ this ->prophesize (PackageEvent::class);
141147
148+ // Mock RootPackageInterface para getPackage()
149+ $ package = $ this ->prophesize (\Composer \Package \RootPackageInterface::class);
150+ $ package ->getName ()->willReturn ('fast-forward/dev-tools ' );
151+ $ this ->composer ->getPackage ()->willReturn ($ package ->reveal ());
152+
142153 $ event ->getComposer ()
143154 ->willReturn ($ this ->composer ->reveal ());
144155 $ event ->getIO ()
@@ -151,8 +162,8 @@ public function onPostPackageUpdateWillInstallScripts(): void
151162
152163 $ data = json_decode (file_get_contents ($ this ->tempComposerFile ), true );
153164 self ::assertArrayHasKey ('scripts ' , $ data );
154- self ::assertSame ('./bin/ dev-tools ' , $ data ['scripts ' ]['dev-tools ' ]);
155- self ::assertSame ('./bin/ dev-tools --fix ' , $ data ['scripts ' ]['dev-tools:fix ' ]);
165+ self ::assertSame ('dev-tools ' , $ data ['scripts ' ]['dev-tools ' ]);
166+ self ::assertSame ('dev-tools --fix ' , $ data ['scripts ' ]['dev-tools:fix ' ]);
156167 }
157168
158169 /**
0 commit comments