-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f82c288
commit a723452
Showing
2 changed files
with
91 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\TestCases\Content; | ||
|
||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\RoutableInterface; | ||
|
||
/** | ||
* Trait to test your implementation of the TemplateInterface. | ||
*/ | ||
trait RoutableTestCaseTrait | ||
{ | ||
abstract protected function getRoutableInstance(DimensionInterface $dimension): RoutableInterface; | ||
|
||
public function testGetLocale(): void | ||
{ | ||
$dimension = $this->prophesize(DimensionInterface::class); | ||
$dimension->getLocale()->willReturn('en'); | ||
|
||
$model = $this->getRoutableInstance($dimension->reveal()); | ||
$this->assertSame('en', $model->getLocale()); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Domain\Model; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\RoutableInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\RoutableTrait; | ||
use Sulu\Bundle\ContentBundle\TestCases\Content\RoutableTestCaseTrait; | ||
|
||
class RoutableTraitTest extends TestCase | ||
{ | ||
use RoutableTestCaseTrait; | ||
|
||
protected function getRoutableInstance(DimensionInterface $dimension): RoutableInterface | ||
{ | ||
return new class($dimension) implements RoutableInterface { | ||
use RoutableTrait; | ||
|
||
/** | ||
* @var DimensionInterface | ||
*/ | ||
private $dimension; | ||
|
||
public function __construct(DimensionInterface $dimension) | ||
{ | ||
$this->dimension = $dimension; | ||
} | ||
|
||
public function getContentClass(): string | ||
{ | ||
return \get_class($this); | ||
} | ||
|
||
public function getContentId() | ||
{ | ||
return 1; | ||
} | ||
|
||
public function getDimension(): DimensionInterface | ||
{ | ||
return $this->dimension; | ||
} | ||
}; | ||
} | ||
} |