‪TYPO3CMS  10.4
RepositoryRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪RepositoryRepositoryTest extends UnitTestCase
27 {
31  protected ‪$mockObjectManager;
32 
36  protected ‪$subject;
37 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->mockObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)->getMock();
43  $this->subject = $this->getMockBuilder(RepositoryRepository::class)
44  ->setMethods(['findAll'])
45  ->setConstructorArgs([$this->mockObjectManager])
46  ->getMock();
47  }
48 
53  {
54  $this->subject
55  ->expects(self::once())
56  ->method('findAll')
57  ->willReturn([]);
58 
59  self::assertNull($this->subject->findOneTypo3OrgRepository());
60  }
61 
66  {
67  $mockModelOne = $this->getMockBuilder(Repository::class)->getMock();
68  $mockModelOne
69  ->expects(self::once())
70  ->method('getTitle')
71  ->willReturn('foo');
72  $mockModelTwo = $this->getMockBuilder(Repository::class)->getMock();
73  $mockModelTwo
74  ->expects(self::once())
75  ->method('getTitle')
76  ->willReturn('TYPO3.org Main Repository');
77 
78  $this->subject
79  ->expects(self::once())
80  ->method('findAll')
81  ->willReturn([$mockModelOne, $mockModelTwo]);
82 
83  self::assertSame($mockModelTwo, $this->subject->findOneTypo3OrgRepository());
84  }
85 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository
Definition: RepositoryRepositoryTest.php:16
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository\RepositoryRepositoryTest\setUp
‪setUp()
Definition: RepositoryRepositoryTest.php:36
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository\RepositoryRepositoryTest\$subject
‪TYPO3 CMS Extensionmanager Domain Repository RepositoryRepository $subject
Definition: RepositoryRepositoryTest.php:34
‪TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
Definition: RepositoryRepository.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository\RepositoryRepositoryTest
Definition: RepositoryRepositoryTest.php:27
‪TYPO3\CMS\Extbase\Object\ObjectManagerInterface
Definition: ObjectManagerInterface.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository\RepositoryRepositoryTest\findOneTypo3OrgRepositoryReturnsNullIfNoRepositoryWithThisTitleExists
‪findOneTypo3OrgRepositoryReturnsNullIfNoRepositoryWithThisTitleExists()
Definition: RepositoryRepositoryTest.php:50
‪TYPO3\CMS\Extensionmanager\Domain\Model\Repository
Definition: Repository.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository\RepositoryRepositoryTest\findOneTypo3OrgRepositoryReturnsRepositoryWithCorrectTitle
‪findOneTypo3OrgRepositoryReturnsRepositoryWithCorrectTitle()
Definition: RepositoryRepositoryTest.php:63
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository\RepositoryRepositoryTest\$mockObjectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $mockObjectManager
Definition: RepositoryRepositoryTest.php:30