Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid type error regarding
setTranslator
with Symfony < 4.2 while s…
…ymfony/translation-contracts is installed fixes #347
- Loading branch information
Showing
6 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests\EventListener; | ||
|
||
use Craue\FormFlowBundle\Tests\UnitTestCase; | ||
use Symfony\Component\Translation\DataCollectorTranslator; | ||
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @group unit | ||
* | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2019 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
abstract class EventListenerNeedsTranslatorTest extends UnitTestCase { | ||
|
||
abstract protected function getListener(); | ||
|
||
/** | ||
* TranslatorInterface (from contracts) was introduced with Symfony 4.2, but could be installed separately by symfony/translation-contracts along with Symfony < 4.2. | ||
* | ||
* @dataProvider dataSetTranslator | ||
* @doesNotPerformAssertions | ||
*/ | ||
public function testSetTranslator($translator) { | ||
$this->getListener()->setTranslator($translator); | ||
} | ||
|
||
public function dataSetTranslator() { | ||
$translators = [ | ||
[$this->createMock(DataCollectorTranslator::class)], | ||
]; | ||
|
||
if (interface_exists(LegacyTranslatorInterface::class)) { | ||
// TODO remove as soon as Symfony >= 4.2 is required | ||
$translators[] = [$this->createMock(LegacyTranslatorInterface::class)]; | ||
} else { | ||
$translators[] = [$this->createMock(TranslatorInterface::class)]; | ||
} | ||
|
||
return $translators; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests\EventListener; | ||
|
||
use Craue\FormFlowBundle\EventListener\FlowExpiredEventListener; | ||
|
||
/** | ||
* @group unit | ||
* | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2019 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class FlowExpiredEventListenerTest extends EventListenerNeedsTranslatorTest { | ||
|
||
protected function getListener() { | ||
return new FlowExpiredEventListener(); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Tests/EventListener/PreviousStepInvalidEventListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests\EventListener; | ||
|
||
use Craue\FormFlowBundle\EventListener\PreviousStepInvalidEventListener; | ||
|
||
/** | ||
* @group unit | ||
* | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2019 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class PreviousStepInvalidEventListenerTest extends EventListenerNeedsTranslatorTest { | ||
|
||
protected function getListener() { | ||
return new PreviousStepInvalidEventListener(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters