Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Apr 8, 2021
2 parents 5b30eee + e93a43b commit ee024a7
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.32.1](https://github.com/sonata-project/SonataDoctrineORMAdminBundle/compare/3.32.0...3.32.1) - 2021-04-06
### Fixed
- [[#1393](https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1393)] Added missing filter declaration in the config ([@VincentLanglet](https://github.com/VincentLanglet))

## [3.32.0](https://github.com/sonata-project/SonataDoctrineORMAdminBundle/compare/3.31.0...3.32.0) - 2021-03-30
### Added
- [[#1355](https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1355)] `ModelManager::reverseTransform()` ([@VincentLanglet](https://github.com/VincentLanglet))
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"psalm/plugin-symfony": "^2.0",
"sonata-project/block-bundle": "^4.2",
"sonata-project/entity-audit-bundle": "^1.1",
"symfony/css-selector": "^4.4 || ^5.2",
"symfony/panther": "^1.0",
"symfony/phpunit-bridge": "^5.2",
"symfony/templating": "^4.4 || ^5.2",
Expand Down
29 changes: 29 additions & 0 deletions tests/App/Admin/SubAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;

/**
* @phpstan-extends AbstractAdmin<\Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Sub>
*/
final class SubAdmin extends AbstractAdmin
{
protected function configureListFields(ListMapper $list): void
{
$list->addIdentifier('id');
$list->add('otherField');
}
}
31 changes: 31 additions & 0 deletions tests/App/DataFixtures/SubFixtures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Sub;

final class SubFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
for ($i = 0; $i < 100; ++$i) {
$sub = new Sub();
$manager->persist($sub);
}

$manager->flush();
}
}
46 changes: 46 additions & 0 deletions tests/App/Entity/Base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity()
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({
* "sub" = "Sub"
* })
*/
abstract class Base
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int|null
*/
private $id = null;

public function getId(): ?int
{
return $this->id;
}

public function setId(?int $id): void
{
$this->id = $id;
}
}
29 changes: 29 additions & 0 deletions tests/App/Entity/Sub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity()
*/
class Sub extends Base
{
/**
* @ORM\Column(options={"default"="HELLO WORLD"})
*
* @var string
*/
private $otherField = 'HELLO WORLD';
}
18 changes: 13 additions & 5 deletions tests/App/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\CarAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\CategoryAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\ItemAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\SubAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Author;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Book;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Car;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Category;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Item;
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Sub;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand All @@ -31,7 +33,6 @@
->load('Sonata\\DoctrineORMAdminBundle\\Tests\\App\\DataFixtures\\', dirname(__DIR__).'/DataFixtures')

->set(CategoryAdmin::class)
->public()
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Category',
Expand All @@ -43,7 +44,6 @@
])

->set(BookAdmin::class)
->public()
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Book',
Expand All @@ -55,7 +55,6 @@
])

->set(AuthorAdmin::class)
->public()
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Author',
Expand All @@ -68,7 +67,6 @@
->call('setTemplate', ['outer_list_rows_list', 'author/list_outer_list_rows_list.html.twig'])

->set(CarAdmin::class)
->public()
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Car',
Expand All @@ -80,7 +78,6 @@
])

->set(ItemAdmin::class)
->public()
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Command item',
Expand All @@ -89,5 +86,16 @@
'',
Item::class,
null,
])

->set(SubAdmin::class)
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Inheritance',
])
->args([
'',
Sub::class,
null,
]);
};
37 changes: 37 additions & 0 deletions tests/Functional/BaseFunctionalTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\Functional;

use Sonata\DoctrineORMAdminBundle\Tests\App\AppKernel;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

abstract class BaseFunctionalTestCase extends WebTestCase
{
/**
* @var KernelBrowser
*/
protected $client;

protected function setUp(): void
{
$this->client = static::createClient();
$this->client->followRedirects();
}

protected static function getKernelClass(): string
{
return AppKernel::class;
}
}
16 changes: 1 addition & 15 deletions tests/Functional/CRUDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,8 @@
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Category;
use Symfony\Component\HttpFoundation\Request;

final class CRUDTest extends BasePantherTestCase
final class CRUDTest extends BaseFunctionalTestCase
{
public function testFilter(): void
{
$this->client->request(Request::METHOD_GET, '/admin/tests/app/category/list');

$this->client->clickLink('Filters');
$this->client->clickLink('Name');

$this->client->submitForm('Filter', [
'filter[name][value]' => 'Novel',
]);

self::assertSelectorTextContains('.sonata-link-identifier', 'Novel');
}

public function testList(): void
{
$this->client->request(Request::METHOD_GET, '/admin/tests/app/category/list');
Expand Down
33 changes: 33 additions & 0 deletions tests/Functional/DatagridTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\Functional;

use Symfony\Component\HttpFoundation\Request;

final class DatagridTest extends BasePantherTestCase
{
public function testFilter(): void
{
$this->client->request(Request::METHOD_GET, '/admin/tests/app/category/list');

$this->client->clickLink('Filters');
$this->client->clickLink('Name');

$this->client->submitForm('Filter', [
'filter[name][value]' => 'Dystopian',
]);

self::assertSelectorTextContains('.sonata-link-identifier', 'Dystopian');
}
}
26 changes: 26 additions & 0 deletions tests/Functional/EntityInheritanceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrineORMAdminBundle\Tests\Functional;

use Symfony\Component\HttpFoundation\Request;

final class EntityInheritanceTest extends BaseFunctionalTestCase
{
public function testList(): void
{
$this->client->request(Request::METHOD_GET, '/admin/tests/app/sub/list');

self::assertResponseIsSuccessful();
}
}

0 comments on commit ee024a7

Please sign in to comment.