diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8d9bf4..e7d720d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,15 +12,15 @@ env: jobs: build: runs-on: ${{ matrix.os }} - name: PHP v${{ matrix.php }}, Symfony v${{ matrix.symfony }} with Mongo v${{ matrix.mongodb }} + name: PHP v${{ matrix.php }}, Symfony v${{ matrix.symfony }} strategy: matrix: include: - - { os: ubuntu-latest, php: 7.3, mongodb: 3.6, symfony: "4.4.*"} - - { os: ubuntu-latest, php: 7.3, mongodb: 3.6, symfony: "5.1.*"} - - { os: ubuntu-latest, php: 7.4, mongodb: 3.6, symfony: "5.2.*"} - - { os: ubuntu-latest, php: 7.4, mongodb: 3.6, symfony: "5.3.*"} - - { os: ubuntu-latest, php: 8.0, mongodb: 3.6, symfony: "5.4.*@dev"} + - { os: ubuntu-latest, php: 7.3, symfony: "4.4.*"} + - { os: ubuntu-latest, php: 7.3, symfony: "5.1.*"} + - { os: ubuntu-latest, php: 7.4, symfony: "5.2.*"} + - { os: ubuntu-latest, php: 7.4, symfony: "5.3.*"} + - { os: ubuntu-latest, php: 8.0, symfony: "5.4.*@dev"} steps: - uses: actions/checkout@v2 @@ -28,7 +28,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: curl,mbstring,xdebug,mongodb + extensions: curl,mbstring,xdebug ini-values: date.timezone="Europe/Paris" coverage: xdebug tools: composer diff --git a/Tests/Cron/ConfigurationTest.php b/Tests/Cron/ConfigurationTest.php index 621f073..90abe85 100644 --- a/Tests/Cron/ConfigurationTest.php +++ b/Tests/Cron/ConfigurationTest.php @@ -15,12 +15,11 @@ public function testFullConfig() $this->assertEquals('project_staging', $configuration->initWithEnv('staging')->getUser()); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Env not availables. Use this: staging - */ public function testInitEnvIsAvailable() { + self::expectException(\InvalidArgumentException::class); + self::expectExceptionMessage('Env not availables. Use this: staging'); + $configuration = new Configuration($this->getFullConfig()); $configuration->initWithEnv('test'); } @@ -61,12 +60,11 @@ public function testEmptyCrons() $this->assertEmpty($configuration->getCrons()); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Env not availables. Use this: staging - */ public function testWithBadEnv() { + self::expectException(\InvalidArgumentException::class); + self::expectExceptionMessage('Env not availables. Use this: staging'); + new Configuration([ 'env_available' => [ 'staging', @@ -77,12 +75,11 @@ public function testWithBadEnv() ]); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage You have missing env. Use this: staging, prod - */ public function testWithMissingEnv() { + self::expectException(\InvalidArgumentException::class); + self::expectExceptionMessage('You have missing env. Use this: staging, prod'); + new Configuration([ 'env_available' => [ 'staging', 'prod', @@ -93,12 +90,11 @@ public function testWithMissingEnv() ]); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Env not availables. Use this: staging - */ public function testWithBadCronEnv() { + self::expectException(\InvalidArgumentException::class); + self::expectExceptionMessage('Env not availables. Use this: staging'); + new Configuration([ 'env_available' => [ 'staging', diff --git a/Tests/Cron/DumpFileTest.php b/Tests/Cron/DumpFileTest.php index 1ecb0db..2432dd1 100644 --- a/Tests/Cron/DumpFileTest.php +++ b/Tests/Cron/DumpFileTest.php @@ -4,6 +4,7 @@ use Lexik\Bundle\CronFileGeneratorBundle\Cron\Configuration; use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFile; +use Lexik\Bundle\CronFileGeneratorBundle\Exception\CronEmptyException; use PHPUnit\Framework\TestCase; use Twig\Environment; @@ -11,13 +12,13 @@ class DumpFileTest extends TestCase { private $outputDir; - protected function setUp() + protected function setUp(): void { $this->outputDir = \sys_get_temp_dir().'/lexik'; @\mkdir($this->outputDir); } - protected function tearDown() + protected function tearDown(): void { @\unlink($this->outputDir.'/cron_file'); \rmdir($this->outputDir); @@ -62,11 +63,10 @@ public function testDumpFile() $this->assertEquals($this->outputDir.'/cron_file', $dumpFile->dumpFile()); } - /** - * @expectedException \Lexik\Bundle\CronFileGeneratorBundle\Exception\CronEmptyException - */ public function testEmptyCron() { + self::expectException(CronEmptyException::class); + $templating = $this->createMock(Environment::class); $templating->expects($this->never())->method('render'); diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php index beea65a..528258c 100644 --- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php +++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php @@ -72,6 +72,8 @@ private function createContainer(array $configs = []) 'kernel.cache_dir' => __DIR__, 'kernel.root_dir' => __DIR__, 'kernel.project_dir' => __DIR__, + 'kernel.build_dir' => __DIR__, + 'kernel.runtime_environment' => 'test', 'kernel.charset' => 'UTF-8', 'kernel.environment' => 'test', 'kernel.debug' => false, diff --git a/Tests/Functional/Command/GenerateCronFileCommandTest.php b/Tests/Functional/Command/GenerateCronFileCommandTest.php index 2704e51..d2754bf 100644 --- a/Tests/Functional/Command/GenerateCronFileCommandTest.php +++ b/Tests/Functional/Command/GenerateCronFileCommandTest.php @@ -21,7 +21,7 @@ public function testGenerateFullConfiguration() $cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir') . '/cron_test'; - $this->assertContains($expected, \file_get_contents($cacheDir)); + $this->assertStringContainsString($expected, \file_get_contents($cacheDir)); } public function testGenerateEmptyCrons() @@ -36,7 +36,7 @@ public function testGenerateEmptyCrons() $expected = 'There is no crons in your configuration. Crons are required for execute the command'; - $this->assertContains($expected, $tester->getDisplay()); + $this->assertStringContainsString($expected, $tester->getDisplay()); } public function testDryRun() @@ -49,9 +49,9 @@ public function testDryRun() $this->assertSame(0, $tester->execute(['env-mode' => 'staging', '--dry-run' => true])); - $this->assertContains('[OK] Dry run generated', $tester->getDisplay()); - $this->assertContains('# send email', $tester->getDisplay()); - $this->assertContains( + $this->assertStringContainsString('[OK] Dry run generated', $tester->getDisplay()); + $this->assertStringContainsString('# send email', $tester->getDisplay()); + $this->assertStringContainsString( '* * * * * project_staging php7.3 path/to/staging app:test --env=staging', $tester->getDisplay() ); diff --git a/Tests/Functional/TestCase.php b/Tests/Functional/TestCase.php index fb8d15b..3c28f81 100644 --- a/Tests/Functional/TestCase.php +++ b/Tests/Functional/TestCase.php @@ -24,7 +24,7 @@ protected static function createKernel(array $options = []) /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $fs = new Filesystem(); $fs->remove(\sys_get_temp_dir().'/LexikCronFileGeneratorBundle/'); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5930985..fb74a25 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,10 +27,6 @@ - - - -