[TASK] Change $fixture to $subject in 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 /**
18 * Test case
19 *
20 */
21 class RepositoryRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
22
23 /**
24 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
25 */
26 protected $mockObjectManager;
27
28 /**
29 * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
30 */
31 protected $subject;
32
33 protected function setUp() {
34 $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
35 /** @var $subject \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
36 $this->subject = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository::class, array('findAll'), array($this->mockObjectManager));
37 }
38
39 /**
40 * @test
41 */
42 public function findOneTypo3OrgRepositoryReturnsNullIfNoRepositoryWithThisTitleExists() {
43
44 $this->subject
45 ->expects($this->once())
46 ->method('findAll')
47 ->will($this->returnValue(array()));
48
49 $this->assertNull($this->subject->findOneTypo3OrgRepository());
50 }
51
52 /**
53 * @test
54 */
55 public function findOneTypo3OrgRepositoryReturnsRepositoryWithCorrectTitle() {
56 $mockModelOne = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class);
57 $mockModelOne
58 ->expects(($this->once()))
59 ->method('getTitle')
60 ->will($this->returnValue('foo'));
61 $mockModelTwo = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class);
62 $mockModelTwo
63 ->expects(($this->once()))
64 ->method('getTitle')
65 ->will($this->returnValue('TYPO3.org Main Repository'));
66
67 $this->subject
68 ->expects($this->once())
69 ->method('findAll')
70 ->will($this->returnValue(array($mockModelOne, $mockModelTwo)));
71
72 $this->assertSame($mockModelTwo, $this->subject->findOneTypo3OrgRepository());
73 }
74
75 }