Skip to content

Commit e7bc99d

Browse files
committed
update tests
1 parent c3c698e commit e7bc99d

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ php:
66
- 5.6
77

88
env:
9+
- SYMFONY_VERSION=2.3.*
910
- SYMFONY_VERSION=2.4.*
1011
- SYMFONY_VERSION=2.5.*
1112
- SYMFONY_VERSION=2.6.*

Tests/Functional/BaseTestCase.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace DTL\Bundle\PhpcrMigrations\Tests\Functional;
1313

14+
use DTL\Bundle\PhpcrMigrations\Command\MigrateCommand;
15+
use DTL\Bundle\PhpcrMigrations\Command\StatusCommand;
1416
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as CmfBaseTestCase;
1517
use Symfony\Component\Console\Tester\CommandTester;
1618

@@ -27,12 +29,22 @@ public function setUp()
2729
}
2830
}
2931

30-
protected function executeCommand($serviceId, $arguments)
32+
protected function executeCommand($command, $arguments)
3133
{
32-
$command = $this->getContainer()->get($serviceId);
34+
$command->setContainer($this->getContainer());
3335
$tester = new CommandTester($command);
3436
$tester->execute($arguments);
3537

3638
return $tester;
3739
}
40+
41+
protected function getMigrateCommand()
42+
{
43+
return new MigrateCommand();
44+
}
45+
46+
protected function getStatusCommand()
47+
{
48+
return new StatusCommand();
49+
}
3850
}

Tests/Functional/MigrateCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MigrateCommandTest extends BaseTestCase
1818
*/
1919
public function testMigrateToLatest()
2020
{
21-
$this->executeCommand('phpcr_migrations.command.migrate', array());
21+
$this->executeCommand($this->getMigrateCommand(), array());
2222

2323
$versionNodes = $this->session->getNode('/jcr:migrations')->getNodes();
2424
$this->assertCount(5, $versionNodes);
@@ -29,7 +29,7 @@ public function testMigrateToLatest()
2929
*/
3030
public function testUpgradeTo()
3131
{
32-
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201401011300'));
32+
$tester = $this->executeCommand($this->getMigrateCommand(), array('to' => '201401011300'));
3333
$display = $tester->getDisplay();
3434

3535
$this->assertContains('Upgrading 1 version', $display);
@@ -43,8 +43,8 @@ public function testUpgradeTo()
4343
*/
4444
public function testUpgradeRevertTo()
4545
{
46-
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array());
47-
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201501011200'));
46+
$tester = $this->executeCommand($this->getMigrateCommand(), array());
47+
$tester = $this->executeCommand($this->getMigrateCommand(), array('to' => '201501011200'));
4848
$display = $tester->getDisplay();
4949

5050
$this->assertContains('Reverting 3 version', $display);

Tests/Functional/StatusCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StatusCommandTest extends BaseTestCase
1818
*/
1919
public function testShowAll()
2020
{
21-
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
21+
$tester = $this->executeCommand($this->getStatusCommand(), array());
2222
$display = $tester->getDisplay();
2323

2424
$this->assertContains('No migrations have been executed', $display);
@@ -29,8 +29,8 @@ public function testShowAll()
2929
*/
3030
public function testShowCurrentVersion()
3131
{
32-
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201501011500'));
33-
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
32+
$tester = $this->executeCommand($this->getMigrateCommand(), array('to' => '201501011500'));
33+
$tester = $this->executeCommand($this->getStatusCommand(), array());
3434
$display = $tester->getDisplay();
3535

3636
$this->assertContains('201501011500', $display);

0 commit comments

Comments
 (0)