Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/App/Admin/AuthorAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @phpstan-extends AbstractAdmin<\Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Author>
*/
final class AuthorAdmin extends AbstractAdmin
class AuthorAdmin extends AbstractAdmin
{
protected function configureListFields(ListMapper $list): void
{
Expand Down
20 changes: 20 additions & 0 deletions tests/App/Admin/AuthorWithSimplePagerAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* 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;

final class AuthorWithSimplePagerAdmin extends AuthorAdmin
{
protected $baseRoutePattern = 'author-with-simple-pager';
protected $baseRouteName = 'author_with_simple_pager';
}
16 changes: 16 additions & 0 deletions tests/App/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
* file that was distributed with this source code.
*/

use Sonata\AdminBundle\Datagrid\Pager;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\AuthorAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\AuthorWithSimplePagerAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\BookAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\CarAdmin;
use Sonata\DoctrineORMAdminBundle\Tests\App\Admin\CategoryAdmin;
Expand Down Expand Up @@ -58,6 +60,20 @@
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Author',
'default' => true,
])
->args([
'',
Author::class,
null,
])
->call('setTemplate', ['outer_list_rows_list', 'author/list_outer_list_rows_list.html.twig'])

->set(AuthorWithSimplePagerAdmin::class)
->tag('sonata.admin', [
'manager_type' => 'orm',
'label' => 'Author with Simple Pager',
'pager_type' => Pager::TYPE_SIMPLE,
])
->args([
'',
Expand Down
30 changes: 30 additions & 0 deletions tests/Functional/SimplePagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* 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 SimplePagerTest extends BaseFunctionalTestCase
{
public function testSimplePagerSameResultsAsPager(): void
{
$crawlerWithPager = $this->client->request(Request::METHOD_GET, '/admin/tests/app/author/list');

$numberOfAuthors = $crawlerWithPager->filter('.js-author-item')->count();

$crawlerWithSimplePager = $this->client->request(Request::METHOD_GET, '/admin/author-with-simple-pager/list');

$this->assertSame($numberOfAuthors, $crawlerWithSimplePager->filter('.js-author-item')->count());
}
}