|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @copyright Copyright (C) Ibexa AS. All rights reserved. |
| 5 | + * @license For full copyright and license information view LICENSE file distributed with this source code. |
| 6 | + */ |
| 7 | +declare(strict_types=1); |
| 8 | + |
| 9 | +namespace Ibexa\Tests\AdminUi\Tab\Dashboard; |
| 10 | + |
| 11 | +use Ibexa\AdminUi\Tab\Dashboard\MyDraftsTab; |
| 12 | +use Ibexa\AdminUi\UI\Dataset\DatasetFactory; |
| 13 | +use Ibexa\Contracts\Core\Repository\ContentService; |
| 14 | +use Ibexa\Contracts\Core\Repository\ContentTypeService; |
| 15 | +use Ibexa\Contracts\Core\Repository\PermissionResolver; |
| 16 | +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; |
| 17 | +use PHPUnit\Framework\TestCase; |
| 18 | +use Symfony\Component\HttpFoundation\Request; |
| 19 | +use Symfony\Component\HttpFoundation\RequestStack; |
| 20 | +use Symfony\Contracts\Translation\TranslatorInterface; |
| 21 | +use Twig\Environment; |
| 22 | +use Twig\Loader\ArrayLoader; |
| 23 | + |
| 24 | +/** |
| 25 | + * @covers \Ibexa\AdminUi\Tab\Dashboard\MyDraftsTab |
| 26 | + */ |
| 27 | +final class MyDraftsTabTest extends TestCase |
| 28 | +{ |
| 29 | + public function testRenderView(): void |
| 30 | + { |
| 31 | + $templateMock = '{{ pager_options.routeName }} | {{ pager_options.pageParameter }}'; |
| 32 | + $twigStub = new Environment( |
| 33 | + new ArrayLoader( |
| 34 | + [ |
| 35 | + '@ibexadesign/ui/dashboard/tab/my_draft_list.html.twig' => $templateMock, |
| 36 | + ] |
| 37 | + ) |
| 38 | + ); |
| 39 | + |
| 40 | + $requestStackMock = $this->createMock(RequestStack::class); |
| 41 | + $configResolverMock = $this->createMock(ConfigResolverInterface::class); |
| 42 | + $tab = new MyDraftsTab( |
| 43 | + $twigStub, |
| 44 | + $this->createMock(TranslatorInterface::class), |
| 45 | + $this->createMock(ContentService::class), |
| 46 | + $this->createMock(ContentTypeService::class), |
| 47 | + $this->createMock(PermissionResolver::class), |
| 48 | + $this->createMock(DatasetFactory::class), |
| 49 | + $requestStackMock, |
| 50 | + $configResolverMock |
| 51 | + ); |
| 52 | + |
| 53 | + $configResolverMock->method('getParameter')->with('pagination.content_draft_limit')->willReturn(10); |
| 54 | + $requestStackMock->method('getCurrentRequest')->willReturn(new Request()); |
| 55 | + |
| 56 | + self::assertSame( |
| 57 | + // see $templateMock |
| 58 | + 'app.page | [mydrafts-page]', |
| 59 | + $tab->renderView( |
| 60 | + [ |
| 61 | + 'pager_options' => [ |
| 62 | + 'routeName' => 'app.page', |
| 63 | + ], |
| 64 | + ] |
| 65 | + ) |
| 66 | + ); |
| 67 | + } |
| 68 | +} |
0 commit comments