mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-10 03:36:12 +01:00
[CLEANUP] Switch to Prophecy
This commit is contained in:
parent
15dc45eca7
commit
1c1f846858
3 changed files with 28 additions and 11 deletions
|
@ -16,6 +16,8 @@ namespace OliverKlee\Tea\Tests\Unit\Controller;
|
|||
|
||||
use OliverKlee\Tea\Controller\TestimonialController;
|
||||
use OliverKlee\Tea\Domain\Repository\TestimonialRepository;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Prophecy\Prophecy\ProphecySubjectInterface;
|
||||
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
|
||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||
|
||||
|
@ -37,12 +39,22 @@ class TestimonialControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
|
|||
protected $subject = null;
|
||||
|
||||
/**
|
||||
* @var ViewInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var ViewInterface|ObjectProphecy
|
||||
*/
|
||||
protected $viewProphecy = null;
|
||||
|
||||
/**
|
||||
* @var ViewInterface|ProphecySubjectInterface
|
||||
*/
|
||||
protected $view = null;
|
||||
|
||||
/**
|
||||
* @var TestimonialRepository|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var TestimonialRepository|ObjectProphecy
|
||||
*/
|
||||
protected $testimonialRepositoryProphecy = null;
|
||||
|
||||
/**
|
||||
* @var TestimonialRepository|ProphecySubjectInterface
|
||||
*/
|
||||
protected $testimonialRepository = null;
|
||||
|
||||
|
@ -50,10 +62,12 @@ class TestimonialControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
|
|||
{
|
||||
$this->subject = new TestimonialController();
|
||||
|
||||
$this->view = $this->getMock(ViewInterface::class);
|
||||
$this->viewProphecy = $this->prophesize(ViewInterface::class);
|
||||
$this->view = $this->viewProphecy->reveal();
|
||||
$this->inject($this->subject, 'view', $this->view);
|
||||
|
||||
$this->testimonialRepository = $this->getMock(TestimonialRepository::class, [], [], '', false);
|
||||
$this->testimonialRepositoryProphecy = $this->prophesize(TestimonialRepository::class);
|
||||
$this->testimonialRepository = $this->testimonialRepositoryProphecy->reveal();
|
||||
$this->inject($this->subject, 'testimonialRepository', $this->testimonialRepository);
|
||||
}
|
||||
|
||||
|
@ -71,10 +85,9 @@ class TestimonialControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
|
|||
public function indexActionPassesAllTestimonialsAsTestimonialsToView()
|
||||
{
|
||||
$allTestimonials = new ObjectStorage();
|
||||
$this->testimonialRepository->expects(self::any())->method('findAll')
|
||||
->will(self::returnValue($allTestimonials));
|
||||
$this->testimonialRepositoryProphecy->findAll()->willReturn($allTestimonials);
|
||||
|
||||
$this->view->expects(self::once())->method('assign')->with('testimonials', $allTestimonials);
|
||||
$this->viewProphecy->assign('testimonials', $allTestimonials)->shouldBeCalled();
|
||||
|
||||
$this->subject->indexAction();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace OliverKlee\Tea\Tests\Unit\Domain\Repository;
|
|||
*/
|
||||
|
||||
use OliverKlee\Tea\Domain\Repository\TeaBeverageRepository;
|
||||
use Prophecy\Prophecy\ProphecySubjectInterface;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||
|
||||
|
@ -36,13 +37,14 @@ class TeaBeverageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
|
|||
protected $subject;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var ObjectManagerInterface|ProphecySubjectInterface
|
||||
*/
|
||||
protected $objectManager = null;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->objectManager = $this->getMock(ObjectManagerInterface::class);
|
||||
$objectManagerProphecy = $this->prophesize(ObjectManagerInterface::class);
|
||||
$this->objectManager = $objectManagerProphecy->reveal();
|
||||
$this->subject = new TeaBeverageRepository($this->objectManager);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace OliverKlee\Tea\Tests\Unit\Domain\Repository;
|
|||
*/
|
||||
|
||||
use OliverKlee\Tea\Domain\Repository\TestimonialRepository;
|
||||
use Prophecy\Prophecy\ProphecySubjectInterface;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||
|
||||
|
@ -36,13 +37,14 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
|
|||
protected $subject;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var ObjectManagerInterface|ProphecySubjectInterface
|
||||
*/
|
||||
protected $objectManager = null;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->objectManager = $this->getMock(ObjectManagerInterface::class);
|
||||
$objectManagerProphecy = $this->prophesize(ObjectManagerInterface::class);
|
||||
$this->objectManager = $objectManagerProphecy->reveal();
|
||||
$this->subject = new TestimonialRepository($this->objectManager);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue