eZ\Publish\Core\Repository\Tests\Service\Integration\UrlWildcardTest::testCreate PHP Method

testCreate() public method

Test for the create() method.
public testCreate ( $sourceUrl, $destinationUrl, $forward )
    public function testCreate($sourceUrl, $destinationUrl, $forward)
    {
        $mockedService = $this->getPartlyMockedURLWildcardService();
        /** @var \PHPUnit_Framework_MockObject_MockObject $handlerMock */
        $handlerMock = $this->getPersistenceMock()->urlWildcardHandler();
        $repositoryMock = $this->getRepositoryMock();
        $sourceUrl = '/' . trim($sourceUrl, '/ ');
        $destinationUrl = '/' . trim($destinationUrl, '/ ');
        $repositoryMock->expects($this->once())->method('hasAccess')->with($this->equalTo('content'), $this->equalTo('urltranslator'))->will($this->returnValue(true));
        $repositoryMock->expects($this->once())->method('beginTransaction');
        $repositoryMock->expects($this->once())->method('commit');
        $handlerMock->expects($this->once())->method('loadAll')->will($this->returnValue(array()));
        $handlerMock->expects($this->once())->method('create')->with($this->equalTo($sourceUrl), $this->equalTo($destinationUrl), $this->equalTo($forward))->will($this->returnValue(new SPIURLWildcard(array('id' => 123456, 'sourceUrl' => $sourceUrl, 'destinationUrl' => $destinationUrl, 'forward' => $forward))));
        $urlWildCard = $mockedService->create($sourceUrl, $destinationUrl, $forward);
        $this->assertEquals(new URLWildcard(array('id' => 123456, 'sourceUrl' => $sourceUrl, 'destinationUrl' => $destinationUrl, 'forward' => $forward)), $urlWildCard);
    }