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