Skip to content

Commit

Permalink
Fix test sf 5 (#7)
Browse files Browse the repository at this point in the history
fix test
  • Loading branch information
gilles-g authored Sep 9, 2021
1 parent 4ee3954 commit d8ed106
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 38 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ 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
- name: "Installing php"
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
Expand Down
28 changes: 12 additions & 16 deletions Tests/Cron/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions Tests/Cron/DumpFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

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;

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);
Expand Down Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions Tests/Functional/Command/GenerateCronFileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/');
Expand Down
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
</whitelist>
</filter>

<php>
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5"/>
</php>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
Expand Down

0 comments on commit d8ed106

Please sign in to comment.