-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
11 changed files
with
161 additions
and
48 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
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,32 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\tests; | ||
|
||
|
||
|
||
use Doctrine\Common\Persistence\ManagerRegistry; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
|
||
class DataGridServiceContainerTest extends KernelTestCase | ||
{ | ||
public function testContainer(){ | ||
$this->assertInstanceOf(ManagerRegistry::class, $this->serviceContainer->getDoctrine()); | ||
$this->assertEquals($this->serviceContainer->getDoctrine(), $this->serviceContainer->get('doctrine')); | ||
|
||
$this->assertInstanceOf(RouterInterface::class, $this->serviceContainer->getRouter()); | ||
$this->assertEquals($this->serviceContainer->getRouter(), $this->serviceContainer->get('router')); | ||
|
||
$this->assertInstanceOf(Environment::class, $this->serviceContainer->getTwig()); | ||
$this->assertEquals($this->serviceContainer->getTwig(), $this->serviceContainer->get('twig')); | ||
|
||
$this->assertInstanceOf(RequestStack::class, $this->serviceContainer->getRequest()); | ||
$this->assertEquals($this->serviceContainer->getRequest(), $this->serviceContainer->get('request')); | ||
|
||
$this->assertInstanceOf(TranslatorInterface::class, $this->serviceContainer->getTranslator()); | ||
$this->assertEquals($this->serviceContainer->getTranslator(), $this->serviceContainer->get('translator')); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\tests; | ||
|
||
|
||
use Pfilsx\DataGrid\DataGridServiceContainer; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
|
||
class KernelTestCase extends \Symfony\Bundle\FrameworkBundle\Test\KernelTestCase | ||
{ | ||
/** | ||
* @var DataGridServiceContainer | ||
*/ | ||
protected $serviceContainer; | ||
|
||
/** | ||
* @var Application | ||
*/ | ||
protected $application; | ||
|
||
protected function setUp(): void | ||
{ | ||
$kernel = self::bootKernel(); | ||
$this->application = new Application($kernel); | ||
$this->application->setAutoExit(false); | ||
$this->application->run(new ArrayInput(array( | ||
'doctrine:schema:drop', | ||
'--force' => true | ||
))); | ||
$this->application->run(new ArrayInput(array( | ||
'doctrine:schema:create' | ||
))); | ||
/** @noinspection PhpParamsInspection */ | ||
$this->serviceContainer = new DataGridServiceContainer( | ||
$kernel->getContainer()->get('doctrine'), | ||
$kernel->getContainer()->get('router'), | ||
$kernel->getContainer()->get('twig'), | ||
$kernel->getContainer()->get('request_stack'), | ||
$kernel->getContainer()->get('translator') | ||
); | ||
} | ||
} |
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
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,41 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\tests\providers; | ||
|
||
|
||
use Pfilsx\DataGrid\Grid\Pager; | ||
use Pfilsx\DataGrid\Grid\Providers\RepositoryDataProvider; | ||
use Pfilsx\tests\app\Entity\Node; | ||
use Pfilsx\tests\OrmTestCase; | ||
|
||
class RepositoryDataProviderTest extends OrmTestCase | ||
{ | ||
/** | ||
* @var RepositoryDataProvider | ||
*/ | ||
private $provider; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->provider = new RepositoryDataProvider($this->getEntityManager()->getRepository(Node::class), $this->serviceContainer->getDoctrine()); | ||
$this->provider->setPager(new Pager()); | ||
} | ||
|
||
public function testGetItems(): void | ||
{ | ||
$items = $this->provider->getItems(); | ||
$this->assertIsArray($items); | ||
$this->assertNotEmpty($items); | ||
$this->assertCount(11, $items); | ||
} | ||
|
||
public function testEmpty(): void | ||
{ | ||
$this->provider->addEqualFilter('id', 12); | ||
$items = $this->provider->getItems(); | ||
$this->assertIsArray($items); | ||
$this->assertEmpty($items); | ||
} | ||
} |