TYPO3 CMS  TYPO3_8-7
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 
20 class RepositoryRepositoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
25  protected $mockObjectManager;
26 
30  protected $subject;
31 
32  protected function setUp()
33  {
34  $this->mockObjectManager = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class)->getMock();
36  $this->subject = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository::class)
37  ->setMethods(['findAll'])
38  ->setConstructorArgs([$this->mockObjectManager])
39  ->getMock();
40  }
41 
46  {
47  $this->subject
48  ->expects($this->once())
49  ->method('findAll')
50  ->will($this->returnValue([]));
51 
52  $this->assertNull($this->subject->findOneTypo3OrgRepository());
53  }
54 
59  {
60  $mockModelOne = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class)->getMock();
61  $mockModelOne
62  ->expects(($this->once()))
63  ->method('getTitle')
64  ->will($this->returnValue('foo'));
65  $mockModelTwo = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class)->getMock();
66  $mockModelTwo
67  ->expects(($this->once()))
68  ->method('getTitle')
69  ->will($this->returnValue('TYPO3.org Main Repository'));
70 
71  $this->subject
72  ->expects($this->once())
73  ->method('findAll')
74  ->will($this->returnValue([$mockModelOne, $mockModelTwo]));
75 
76  $this->assertSame($mockModelTwo, $this->subject->findOneTypo3OrgRepository());
77  }
78 }