diff --git a/.gitignore b/.gitignore index 14227d1..55165e2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ /.idea/ /.project /.webprj +/bin/ /composer.lock /nbproject /vendor/ +/web/ diff --git a/Tests/Integration/Composer/ScriptsTest.php b/Tests/Integration/Composer/ScriptsTest.php new file mode 100644 index 0000000..01c8349 --- /dev/null +++ b/Tests/Integration/Composer/ScriptsTest.php @@ -0,0 +1,89 @@ + + */ +class ScriptsTest extends TestCase +{ + /** + * @test + */ + public function webDirectoryHasBeenCreated() + { + self::assertDirectoryExists($this->getAbsoluteWebDirectoryPath()); + } + + /** + * @return string + */ + private function getAbsoluteWebDirectoryPath(): string + { + return dirname(__DIR__, 3) . '/web/'; + } + + /** + * @return string[][] + */ + public function webDirectoryFilesDataProvider(): array + { + return [ + 'production entry point' => ['app.php'], + 'development entry point' => ['app_dev.php'], + 'testing entry point' => ['app_test.php'], + '.htaccess' => ['.htaccess'], + ]; + } + + /** + * @test + * @param string $fileName + * @dataProvider webDirectoryFilesDataProvider + */ + public function webDirectoryFilesExist(string $fileName) + { + self::assertFileExists($this->getAbsoluteWebDirectoryPath() . $fileName); + } + + /** + * @test + */ + public function binariesDirectoryHasBeenCreated() + { + self::assertDirectoryExists($this->getAbsoluteBinariesDirectoryPath()); + } + + /** + * @return string + */ + private function getAbsoluteBinariesDirectoryPath(): string + { + return dirname(__DIR__, 3) . '/bin/'; + } + + /** + * @return string[][] + */ + public function binariesDataProvider(): array + { + return [ + 'Symfony console' => ['console'], + ]; + } + + /** + * @test + * @param string $fileName + * @dataProvider binariesDataProvider + */ + public function binariesExist(string $fileName) + { + self::assertFileExists($this->getAbsoluteBinariesDirectoryPath() . $fileName); + } +} diff --git a/composer.json b/composer.json index 451463b..295b1b5 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,22 @@ "PhpList\\RestBundle\\Tests\\": "Tests/" } }, + "scripts": { + "binaries": [ + "PhpList\\PhpList4\\Composer\\ScriptHandler::createBinaries" + ], + "document-root": [ + "PhpList\\PhpList4\\Composer\\ScriptHandler::createPublicWebDirectory" + ], + "post-install-cmd": [ + "@binaries", + "@document-root" + ], + "post-update-cmd": [ + "@binaries", + "@document-root" + ] + }, "extra": { "branch-alias": { "dev-master": "4.0.x-dev"