-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy Container trait (from core-bundle)
- Loading branch information
Showing
3 changed files
with
114 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,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the datatables-bundle package. | ||
* | ||
* (c) 2018 WEBEWEB | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace WBW\Bundle\DataTablesBundle\Symfony\DependencyInjection\Container; | ||
|
||
use Psr\Container\ContainerInterface; | ||
|
||
/** | ||
* Container trait. | ||
* | ||
* @author webeweb <https://github.com/webeweb> | ||
* @package WBW\Bundle\DataTablesBundle\Symfony\DependencyInjection\Container | ||
*/ | ||
trait ContainerTrait { | ||
|
||
/** | ||
* Container. | ||
* | ||
* @var ContainerInterface|null | ||
*/ | ||
private $container; | ||
|
||
/** | ||
* Get the container. | ||
* | ||
* @return ContainerInterface|null Returns the container. | ||
*/ | ||
public function getContainer(): ?ContainerInterface { | ||
return $this->container; | ||
} | ||
|
||
/** | ||
* Set the container. | ||
* | ||
* @param ContainerInterface|null $container The container. | ||
* @return self Returns this instance. | ||
*/ | ||
protected function setContainer(?ContainerInterface $container): self { | ||
$this->container = $container; | ||
return $this; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Tests/Fixtures/Symfony/DependencyInjection/Container/TestContainerTrait.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,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the datatables-bundle package. | ||
* | ||
* (c) 2018 WEBEWEB | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace WBW\Bundle\DataTablesBundle\Tests\Fixtures\Symfony\DependencyInjection\Container; | ||
|
||
use WBW\Bundle\DataTablesBundle\Symfony\DependencyInjection\Container\ContainerTrait; | ||
|
||
/** | ||
* Test container trait. | ||
* | ||
* @author webeweb <https://github.com/webeweb> | ||
* @package WBW\Bundle\DataTablesBundle\Tests\Fixtures\Symfony\DependencyInjection\Container | ||
*/ | ||
class TestContainerTrait { | ||
|
||
use ContainerTrait { | ||
setContainer as public; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Tests/Symfony/DependencyInjection/Container/ContainerTraitTest.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,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the datatables-bundle package. | ||
* | ||
* (c) 2018 WEBEWEB | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace WBW\Bundle\DataTablesBundle\Tests\Symfony\DependencyInjection\Container; | ||
|
||
use WBW\Bundle\DataTablesBundle\Tests\AbstractTestCase; | ||
use WBW\Bundle\DataTablesBundle\Tests\Fixtures\Symfony\DependencyInjection\Container\TestContainerTrait; | ||
|
||
/** | ||
* Container trait test. | ||
* | ||
* @author webeweb <https://github.com/webeweb> | ||
* @package WBW\Bundle\DataTablesBundle\Tests\Symfony\DependencyInjection\Container | ||
*/ | ||
class ContainerTraitTest extends AbstractTestCase { | ||
|
||
/** | ||
* Test setContainer() | ||
* | ||
* @return void | ||
*/ | ||
public function testSetContainer(): void { | ||
|
||
$obj = new TestContainerTrait(); | ||
|
||
$obj->setContainer($this->containerBuilder); | ||
$this->assertSame($this->containerBuilder, $obj->getContainer()); | ||
} | ||
} |