Skip to content

Commit

Permalink
add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Jul 7, 2020
1 parent 0ea5f9d commit e4ce79c
Show file tree
Hide file tree
Showing 25 changed files with 392 additions and 45 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"gedmo/doctrine-extensions": "^2.4",
"knplabs/doctrine-behaviors": "^2.0.6",
"phpunit/phpunit": "^9.1.3",
"sonata-project/admin-bundle": "^3.61",
"sonata-project/admin-bundle": "^3.68",
"sonata-project/doctrine-orm-admin-bundle": "^3.20",
"sonata-project/easy-extends-bundle": "^2.5",
"sonata-project/media-bundle": "^3.24",
Expand Down
2 changes: 1 addition & 1 deletion packages/basic-page-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"knplabs/doctrine-behaviors": "^2.0.6",
"runroom-packages/render-event-bundle": "^0.8",
"runroom-packages/seo-bundle": "^0.8",
"sonata-project/admin-bundle": "^3.61",
"sonata-project/admin-bundle": "^3.68",
"sonata-project/doctrine-orm-admin-bundle": "^3.20",
"symfony/config": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/basic-page-bundle/tests/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
]);

$container->loadFromExtension('doctrine', [
'dbal' => ['url' => 'sqlite://:memory:'],
'dbal' => ['url' => 'sqlite://:memory:', 'logging' => false],
'orm' => ['auto_mapping' => true],
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor-sonata-media-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^7.3",
"sonata-project/admin-bundle": "^3.61",
"sonata-project/admin-bundle": "^3.68",
"sonata-project/media-bundle": "^3.24",
"symfony/config": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/cookies-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"knplabs/doctrine-behaviors": "^2.0.6",
"runroom-packages/form-handler-bundle": "^0.8",
"runroom-packages/render-event-bundle": "^0.8",
"sonata-project/admin-bundle": "^3.61",
"sonata-project/admin-bundle": "^3.68",
"sonata-project/doctrine-orm-admin-bundle": "^3.20",
"symfony/config": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
"symfony/event-dispatcher": "^4.4 || ^5.1",
Expand Down
27 changes: 23 additions & 4 deletions packages/cookies-bundle/tests/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@

namespace Runroom\CookiesBundle\Tests\App;

use A2lix\AutoFormBundle\A2lixAutoFormBundle;
use A2lix\TranslationFormBundle\A2lixTranslationFormBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle;
use FOS\CKEditorBundle\FOSCKEditorBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Knp\DoctrineBehaviors\DoctrineBehaviorsBundle;
use Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle;
use Runroom\CookiesBundle\RunroomCookiesBundle;
use Runroom\FormHandlerBundle\RunroomFormHandlerBundle;
use Runroom\RenderEventBundle\RunroomRenderEventBundle;
use Sonata\AdminBundle\SonataAdminBundle;
use Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
Expand All @@ -36,16 +42,23 @@ class Kernel extends BaseKernel
public function registerBundles(): iterable
{
return [
new A2lixAutoFormBundle(),
new A2lixTranslationFormBundle(),
new DoctrineBehaviorsBundle(),
new DoctrineBundle(),
new KnpMenuBundle(),
new FidryAliceDataFixturesBundle(),
new FOSCKEditorBundle(),
new FrameworkBundle(),
new NelmioAliceBundle(),
new SecurityBundle(),
new SonataAdminBundle(),
new SonataDoctrineORMAdminBundle(),
new TwigBundle(),

new RunroomFormHandlerBundle(),
new RunroomRenderEventBundle(),
new RunroomCookiesBundle(),
new SecurityBundle(),
new TwigBundle(),
];
}

Expand All @@ -66,19 +79,21 @@ public function getProjectDir(): string

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$container->setParameter('kernel.default_locale', 'en');

$container->loadFromExtension('framework', [
'test' => true,
'router' => ['utf8' => true],
'secret' => 'secret',
'session' => null,
'session' => ['storage_id' => 'session.storage.mock_file'],
]);

$container->loadFromExtension('security', [
'firewalls' => ['main' => ['anonymous' => true]],
]);

$container->loadFromExtension('doctrine', [
'dbal' => ['url' => 'sqlite://:memory:'],
'dbal' => ['url' => 'sqlite://:memory:', 'logging' => false],
'orm' => ['auto_mapping' => true],
]);

Expand All @@ -87,6 +102,10 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
'strict_variables' => '%kernel.debug%',
]);

$container->loadFromExtension('a2lix_translation_form', [
'locales' => ['es', 'en', 'ca'],
]);

$container->loadFromExtension('runroom_cookies', [
'cookies' => [
'mandatory_cookies' => [[
Expand Down
42 changes: 42 additions & 0 deletions packages/cookies-bundle/tests/Integration/CookiesPageAdminTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Runroom package.
*
* (c) Runroom <runroom@runroom.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Runroom\CookiesPageBundle\Tests\Integration;

use Runroom\CookiesBundle\Admin\CookiesPageAdmin;
use Runroom\Testing\TestCase\SonataAdminTestCase;

class CookiesPageAdminTest extends SonataAdminTestCase
{
/** @test */
public function itHasAllFormFields(): void
{
$this->assertAdminFormContainsField('translations');
}

/** @test */
public function itDoesNotHaveDisabledRoutes(): void
{
$this->assertAdminRoutesDoesContainRoute('edit');
$this->assertAdminRoutesDoesNotContainRoute('show');
$this->assertAdminRoutesDoesNotContainRoute('delete');
$this->assertAdminRoutesDoesNotContainRoute('list');
$this->assertAdminRoutesDoesNotContainRoute('batch');
$this->assertAdminRoutesDoesNotContainRoute('export');
}

protected function getAdminClass(): string
{
return CookiesPageAdmin::class;
}
}
3 changes: 2 additions & 1 deletion packages/redirection-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"doctrine/doctrine-bundle": "^2.1",
"doctrine/orm": "^2.7",
"doctrine/persistence": "^1.3 || ^2.0",
"sonata-project/admin-bundle": "^3.61",
"sonata-project/admin-bundle": "^3.68",
"sonata-project/doctrine-orm-admin-bundle": "^3.20",
"symfony/config": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
"symfony/doctrine-bridge": "^4.4 || ^5.1",
Expand Down
22 changes: 21 additions & 1 deletion packages/redirection-bundle/tests/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle;
use Runroom\RedirectionBundle\RunroomRedirectionBundle;
use Sonata\AdminBundle\SonataAdminBundle;
use Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
Expand All @@ -34,7 +39,13 @@ public function registerBundles(): iterable
new DoctrineBundle(),
new FidryAliceDataFixturesBundle(),
new FrameworkBundle(),
new KnpMenuBundle(),
new NelmioAliceBundle(),
new SecurityBundle(),
new SonataAdminBundle(),
new SonataDoctrineORMAdminBundle(),
new TwigBundle(),

new RunroomRedirectionBundle(),
];
}
Expand Down Expand Up @@ -62,8 +73,12 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
'secret' => 'secret',
]);

$container->loadFromExtension('security', [
'firewalls' => ['main' => ['anonymous' => true]],
]);

$container->loadFromExtension('doctrine', [
'dbal' => ['url' => 'sqlite://:memory:'],
'dbal' => ['url' => 'sqlite://:memory:', 'logging' => false],
'orm' => [
'auto_mapping' => true,
'mappings' => [
Expand All @@ -77,6 +92,11 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
],
]);

$container->loadFromExtension('twig', [
'exception_controller' => null,
'strict_variables' => '%kernel.debug%',
]);

$container->loadFromExtension('runroom_redirection', [
'enable_automatic_redirections' => true,
'automatic_redirections' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Runroom package.
*
* (c) Runroom <runroom@runroom.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Runroom\RedirectionBundle\Tests\Integration;

use Runroom\RedirectionBundle\Admin\RedirectAdmin;
use Runroom\Testing\TestCase\SonataAdminTestCase;

class RedirectAdminTest extends SonataAdminTestCase
{
/** @test */
public function itHasAllListFields(): void
{
$this->assertAdminListContainsField('source');
$this->assertAdminListContainsField('destination');
$this->assertAdminListContainsField('httpCode');
$this->assertAdminListContainsField('publish');
$this->assertAdminListContainsField('automatic');
$this->assertAdminListContainsField('_action');
}

/** @test */
public function itHasAllFormFields(): void
{
$this->assertAdminFormContainsField('source');
$this->assertAdminFormContainsField('destination');
$this->assertAdminFormContainsField('httpCode');
$this->assertAdminFormContainsField('publish');
$this->assertAdminFormContainsField('automatic');
}

/** @test */
public function itHasAllFilterFields(): void
{
$this->assertAdminFilterContainsField('source');
$this->assertAdminFilterContainsField('destination');
$this->assertAdminFilterContainsField('httpCode');
$this->assertAdminFilterContainsField('automatic');
$this->assertAdminFilterContainsField('publish');
}

protected function getAdminClass(): string
{
return RedirectAdmin::class;
}
}
3 changes: 2 additions & 1 deletion packages/seo-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"doctrine/persistence": "^1.3 || ^2.0",
"knplabs/doctrine-behaviors": "^2.0.6",
"runroom-packages/render-event-bundle": "^0.8",
"sonata-project/admin-bundle": "^3.61",
"sonata-project/admin-bundle": "^3.68",
"sonata-project/easy-extends-bundle": "^2.5",
"sonata-project/doctrine-orm-admin-bundle": "^3.20",
"sonata-project/media-bundle": "^3.24",
"symfony/config": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
Expand Down
13 changes: 7 additions & 6 deletions packages/seo-bundle/src/Admin/MetaInformationAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

final class MetaInformationAdmin extends AbstractAdmin
{
/** @var array{ _page: int, _sort_order: 'ASC'|'DESC', _sort_by: string } */
protected $datagridValues = [
'_page' => 1,
'_sort_order' => 'ASC',
'_sort_by' => 'routeName',
];
/** @param array{ _page: int, _sort_order: 'ASC'|'DESC', _sort_by: string } $sortValues */
protected function configureDefaultSortValues(array &$sortValues): void
{
$sortValues['_page'] = 1;
$sortValues['_sort_order'] = 'ASC';
$sortValues['_sort_by'] = 'routeName';
}

protected function configureRoutes(RouteCollection $collection): void
{
Expand Down
Loading

0 comments on commit e4ce79c

Please sign in to comment.