[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Domain / Repository / RepositoryRepositoryTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository;
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
19 /**
20 * Test case
21 */
22 class RepositoryRepositoryTest extends UnitTestCase
23 {
24 /**
25 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
26 */
27 protected $mockObjectManager;
28
29 /**
30 * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
31 */
32 protected $subject;
33
34 protected function setUp()
35 {
36 $this->mockObjectManager = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class)->getMock();
37 /** @var $subject \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
38 $this->subject = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository::class)
39 ->setMethods(['findAll'])
40 ->setConstructorArgs([$this->mockObjectManager])
41 ->getMock();
42 }
43
44 /**
45 * @test
46 */
47 public function findOneTypo3OrgRepositoryReturnsNullIfNoRepositoryWithThisTitleExists()
48 {
49 $this->subject
50 ->expects($this->once())
51 ->method('findAll')
52 ->will($this->returnValue([]));
53
54 $this->assertNull($this->subject->findOneTypo3OrgRepository());
55 }
56
57 /**
58 * @test
59 */
60 public function findOneTypo3OrgRepositoryReturnsRepositoryWithCorrectTitle()
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 }