Skip to content

Commit 46dedbe

Browse files
committed
merge #146 conflict
1 parent 4173808 commit 46dedbe

File tree

10 files changed

+106
-156
lines changed

10 files changed

+106
-156
lines changed

.travis.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,21 @@ language: php
22

33
matrix:
44
include:
5-
- php: 7.1
6-
env: SYMFONY_VERSION=3.4.*
75
- php: 7.2
8-
env: SYMFONY_VERSION=3.4.*
6+
env: DEPENDENCIES="symfony/lts:3"
97
- php: 7.3
10-
env: SYMFONY_VERSION=3.4.*
11-
- php: 7.1
12-
env: SYMFONY_VERSION=4.4.*
8+
env: DEPENDENCIES="symfony/lts:3"
9+
- php: 7.4
10+
env: DEPENDENCIES="symfony/lts:3"
1311
- php: 7.2
14-
env: SYMFONY_VERSION=4.4.*
12+
env: DEPENDENCIES="symfony/lts:4.x-dev"
1513
- php: 7.3
16-
env: SYMFONY_VERSION=4.4.*
14+
env: DEPENDENCIES="symfony/lts:4.x-dev"
1715
- php: 7.4
18-
env: SYMFONY_VERSION=4.4.*
16+
env: DEPENDENCIES="symfony/lts:4.x-dev"
1917
- php: 7.2
20-
env: SYMFONY_VERSION=5.0.*
2118
- php: 7.3
22-
env: SYMFONY_VERSION=5.0.*
23-
- php: 7.4snapshot
24-
env: SYMFONY_VERSION=5.0.*
25-
- php: nightly
26-
env: SYMFONY_VERSION=5.0.*
19+
- php: 7.4
2720

2821
allow_failures:
2922
- php: nightly
@@ -35,9 +28,8 @@ branches:
3528

3629
before_script:
3730
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d && echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
38-
- composer self-update
39-
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
40-
- composer update --prefer-dist
31+
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
32+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
4133

4234
script:
4335
- mkdir -p build/logs

Controller/BaseController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace JMose\CommandSchedulerBundle\Controller;
44

55
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6-
use Symfony\Component\Translation\TranslatorInterface as TranslatorComponentInterface; // For Symfony 3.4
7-
use Symfony\Contracts\Translation\TranslatorInterface as TranslatorContractsInterface; // For Symfony 4+
6+
use Symfony\Component\Translation\TranslatorInterface as ComponentTranslatorInterface;
7+
use Symfony\Contracts\Translation\TranslatorInterface as ContractsTranslatorInterface;
88

99
/**
1010
* Class BaseController
@@ -20,7 +20,7 @@ abstract class BaseController extends AbstractController
2020
private $managerName;
2121

2222
/**
23-
* @var TranslatorInterface
23+
* @var ContractsTranslatorInterface|ComponentTranslatorInterface
2424
*/
2525
protected $translator;
2626

@@ -33,7 +33,7 @@ public function setManagerName($managerName)
3333
}
3434

3535
/**
36-
* @param TranslatorComponentInterface|TranslatorContractsInterface $translator
36+
* @param ContractsTranslatorInterface|ComponentTranslatorInterface $translator
3737
*/
3838
public function setTranslator($translator)
3939
{

Tests/Command/ExecuteCommandTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Liip\FunctionalTestBundle\Test\WebTestCase;
66
use Liip\TestFixturesBundle\Test\FixturesTrait;
7+
use JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData;
78

89
/**
910
* Class ExecuteCommandTest
@@ -19,13 +20,9 @@ class ExecuteCommandTest extends WebTestCase
1920
public function testExecute()
2021
{
2122
//DataFixtures create 4 records
22-
$this->loadFixtures(
23-
array(
24-
'JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData'
25-
)
26-
);
23+
$this->loadFixtures(array(LoadScheduledCommandData::class));
2724

28-
$output = $this->runCommand('scheduler:execute')->getDisplay();
25+
$output = $this->runCommand('scheduler:execute', [], true)->getDisplay();
2926

3027
$this->assertStringStartsWith('Start : Execute all scheduled command', $output);
3128
$this->assertRegExp('/debug:container should be executed/', $output);
@@ -53,7 +50,8 @@ public function testExecuteWithNoOutput()
5350
'scheduler:execute',
5451
array(
5552
'--no-output' => true
56-
)
53+
),
54+
true
5755
)->getDisplay();
5856

5957
$this->assertEquals('', $output);
@@ -78,7 +76,8 @@ public function testExecuteWithDump()
7876
'scheduler:execute',
7977
array(
8078
'--dump' => true
81-
)
79+
),
80+
true
8281
)->getDisplay();
8382

8483
$this->assertStringStartsWith('Start : Dump all scheduled command', $output);

Tests/Command/MonitorCommandTest.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Liip\FunctionalTestBundle\Test\WebTestCase;
66
use Liip\TestFixturesBundle\Test\FixturesTrait;
7+
use JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData;
78

89
/**
910
* Class MonitorCommandTest
@@ -21,7 +22,7 @@ class MonitorCommandTest extends WebTestCase
2122
/**
2223
* {@inheritDoc}
2324
*/
24-
public function setUp()
25+
public function setUp(): void
2526
{
2627
self::bootKernel();
2728

@@ -36,19 +37,10 @@ public function setUp()
3637
public function testExecuteWithError()
3738
{
3839
//DataFixtures create 4 records
39-
$this->loadFixtures(
40-
array(
41-
'JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData'
42-
)
43-
);
40+
$this->loadFixtures(array(LoadScheduledCommandData::class));
4441

4542
// One command is locked in fixture (2), another have a -1 return code as lastReturn (4)
46-
$output = $this->runCommand(
47-
'scheduler:monitor',
48-
array(
49-
'--dump' => true
50-
)
51-
)->getDisplay();
43+
$output = $this->runCommand('scheduler:monitor', ['--dump' => true], true)->getDisplay();
5244

5345
$this->assertRegExp('/two:/', $output);
5446
$this->assertRegExp('/four:/', $output);
@@ -60,11 +52,7 @@ public function testExecuteWithError()
6052
public function testExecuteWithoutError()
6153
{
6254
//DataFixtures create 4 records
63-
$this->loadFixtures(
64-
array(
65-
'JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData'
66-
)
67-
);
55+
$this->loadFixtures(array(LoadScheduledCommandData::class));
6856

6957
$two = $this->em->getRepository('JMoseCommandSchedulerBundle:ScheduledCommand')->find(2);
7058
$four = $this->em->getRepository('JMoseCommandSchedulerBundle:ScheduledCommand')->find(4);
@@ -79,7 +67,8 @@ public function testExecuteWithoutError()
7967
'scheduler:monitor',
8068
array(
8169
'--dump' => true
82-
)
70+
),
71+
true
8372
)->getDisplay();
8473

8574
$this->assertStringStartsWith('No errors found.', $output);

Tests/Command/StartStopSchedulerCommandTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use JMose\CommandSchedulerBundle\Command\StartSchedulerCommand;
66
use Liip\FunctionalTestBundle\Test\WebTestCase;
77
use Liip\TestFixturesBundle\Test\FixturesTrait;
8+
use JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData;
89

910
/**
1011
* Class StartStopSchedulerCommandTest
@@ -20,16 +21,12 @@ class StartStopSchedulerCommandTest extends WebTestCase
2021
public function testStartAndStopScheduler()
2122
{
2223
//DataFixtures create 4 records
23-
$this->loadFixtures(
24-
array(
25-
'JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData'
26-
)
27-
);
24+
$this->loadFixtures([LoadScheduledCommandData::class]);
2825

2926
$pidFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.StartSchedulerCommand::PID_FILE;
3027

3128

32-
$output = $this->runCommand('scheduler:start')->getDisplay();
29+
$output = $this->runCommand('scheduler:start', [], true)->getDisplay();
3330
$this->assertStringStartsWith('Command scheduler started in non-blocking mode...', $output);
3431
$this->assertFileExists($pidFile);
3532

Tests/Command/UnlockCommandTest.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use JMose\CommandSchedulerBundle\Entity\ScheduledCommand;
66
use Liip\FunctionalTestBundle\Test\WebTestCase;
77
use Liip\TestFixturesBundle\Test\FixturesTrait;
8+
use JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData;
89

910
/**
1011
* Class UnlockCommandTest
@@ -22,7 +23,7 @@ class UnlockCommandTest extends WebTestCase {
2223
/**
2324
* {@inheritDoc}
2425
*/
25-
public function setUp() {
26+
public function setUp(): void {
2627
self::bootKernel();
2728

2829
$this->em = static::$kernel->getContainer()
@@ -35,14 +36,10 @@ public function setUp() {
3536
*/
3637
public function testUnlockAll() {
3738
//DataFixtures create 4 records
38-
$this->loadFixtures(
39-
['JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData']
40-
);
39+
$this->loadFixtures([LoadScheduledCommandData::class]);
4140

4241
// One command is locked in fixture (2), another have a -1 return code as lastReturn (4)
43-
$output = $this->runCommand(
44-
'scheduler:unlock', ['--all' => true]
45-
)->getDisplay();
42+
$output = $this->runCommand('scheduler:unlock', ['--all' => true], true)->getDisplay();
4643

4744
$this->assertRegExp('/"two"/', $output);
4845
$this->assertNotRegExp('/"one"/', $output);
@@ -59,14 +56,10 @@ public function testUnlockAll() {
5956
*/
6057
public function testUnlockByName() {
6158
//DataFixtures create 4 records
62-
$this->loadFixtures(
63-
['JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData']
64-
);
59+
$this->loadFixtures([LoadScheduledCommandData::class]);
6560

6661
// One command is locked in fixture (2), another have a -1 return code as lastReturn (4)
67-
$output = $this->runCommand(
68-
'scheduler:unlock', ['name' => 'two']
69-
)->getDisplay();
62+
$output = $this->runCommand('scheduler:unlock', ['name' => 'two'], true)->getDisplay();
7063

7164
$this->assertRegExp('/"two"/', $output);
7265

@@ -81,13 +74,13 @@ public function testUnlockByName() {
8174
*/
8275
public function testUnlockByNameWithTimout() {
8376
//DataFixtures create 4 records
84-
$this->loadFixtures(
85-
['JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData']
86-
);
77+
$this->loadFixtures([LoadScheduledCommandData::class]);
8778

8879
// One command is locked in fixture with last execution two days ago (2), another have a -1 return code as lastReturn (4)
8980
$output = $this->runCommand(
90-
'scheduler:unlock', ['name' => 'two', '--lock-timeout' => 3 * 24 * 60 * 60 ]
81+
'scheduler:unlock',
82+
['name' => 'two', '--lock-timeout' => 3 * 24 * 60 * 60],
83+
true
9184
)->getDisplay();
9285

9386
$this->assertRegExp('/Skipping/', $output);

Tests/Controller/DetailControllerTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Liip\FunctionalTestBundle\Test\WebTestCase;
66
use Liip\TestFixturesBundle\Test\FixturesTrait;
7+
use JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData;
78

89
/**
910
* Class DetailControllerTest
@@ -18,9 +19,9 @@ class DetailControllerTest extends WebTestCase
1819
*/
1920
public function testInitNewScheduledCommand()
2021
{
22+
$client = parent::createClient();
2123
$this->loadFixtures(array());
2224

23-
$client = parent::createClient();
2425
$crawler = $client->request('GET', '/command-scheduler/detail/new');
2526
$this->assertEquals(1, $crawler->filter('button[id="command_scheduler_detail_save"]')->count());
2627
}
@@ -30,12 +31,10 @@ public function testInitNewScheduledCommand()
3031
*/
3132
public function testInitEditScheduledCommand()
3233
{
34+
$client = parent::createClient();
3335
//DataFixtures create 4 records
34-
$this->loadFixtures(array(
35-
'JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData'
36-
));
36+
$this->loadFixtures(array(LoadScheduledCommandData::class));
3737

38-
$client = parent::createClient();
3938
$crawler = $client->request('GET', '/command-scheduler/detail/edit/1');
4039
$this->assertEquals(1, $crawler->filter('button[id="command_scheduler_detail_save"]')->count());
4140

@@ -48,20 +47,22 @@ public function testInitEditScheduledCommand()
4847
'command_scheduler_detail[arguments]' => "--help",
4948
'command_scheduler_detail[cronExpression]' => "@daily",
5049
'command_scheduler_detail[logFile]' => "one.log",
51-
'command_scheduler_detail[priority]' => "100"
50+
'command_scheduler_detail[priority]' => "100",
51+
'command_scheduler_detail[save]' => '',
5252
);
5353

54-
$this->assertArraySubset($fixtureSet, $form->getValues());
54+
$this->assertEquals($fixtureSet, $form->getValues());
5555
}
5656

5757
/**
5858
* Test new scheduling creation
5959
*/
6060
public function testNewSave()
6161
{
62+
$client = parent::createClient();
63+
6264
$this->loadFixtures(array());
6365

64-
$client = parent::createClient();
6566
$client->followRedirects(true);
6667
$crawler = $client->request('GET', '/command-scheduler/detail/new');
6768
$buttonCrawlerNode = $crawler->selectButton('Save');
@@ -86,12 +87,11 @@ public function testNewSave()
8687
*/
8788
public function testEditSave()
8889
{
90+
$client = parent::createClient();
91+
8992
//DataFixtures create 4 records
90-
$this->loadFixtures(array(
91-
'JMose\CommandSchedulerBundle\Fixtures\ORM\LoadScheduledCommandData'
92-
));
93+
$this->loadFixtures(array(LoadScheduledCommandData::class));
9394

94-
$client = parent::createClient();
9595
$client->followRedirects(true);
9696
$crawler = $client->request('GET', '/command-scheduler/detail/edit/1');
9797
$buttonCrawlerNode = $crawler->selectButton('Save');

0 commit comments

Comments
 (0)