本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::expects方法的具体用法?PHP DocumentManager::expects怎么用?PHP DocumentManager::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->dm = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
$this->dm->expects($this->once())->method('find')->will($this->returnValue(new \stdClass()));
$this->defaultModelManager = $this->getMockBuilder('Sonata\\DoctrinePHPCRAdminBundle\\Model\\ModelManager')->disableOriginalConstructor()->getMock();
$this->translator = $this->getMockBuilder('Symfony\\Component\\Translation\\TranslatorInterface')->disableOriginalConstructor()->getMock();
$this->assetHelper = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock();
$this->pool = $this->getMockBuilder('Sonata\\AdminBundle\\Admin\\Pool')->disableOriginalConstructor()->getMock();
}
示例2: createGuesser
/**
* Create the guesser for this test.
*
* @return GuesserInterface
*/
protected function createGuesser()
{
$this->registry = $this->getMockBuilder('\\Doctrine\\Bundle\\PHPCRBundle\\ManagerRegistry')->disableOriginalConstructor()->getMock();
$this->manager = $this->getMockBuilder('\\Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
$this->metadata = $this->getMockBuilder('\\Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
$this->registry->expects($this->any())->method('getManagerForClass')->with($this->equalTo('Symfony\\Cmf\\Bundle\\SeoBundle\\Tests\\Unit\\Sitemap\\LastModifiedGuesserTest'))->will($this->returnValue($this->manager));
$this->manager->expects($this->any())->method('getClassMetadata')->with($this->equalTo('Symfony\\Cmf\\Bundle\\SeoBundle\\Tests\\Unit\\Sitemap\\LastModifiedGuesserTest'))->will($this->returnValue($this->metadata));
$this->metadata->expects($this->any())->method('getMixins')->will($this->returnValue(array('mix:lastModified')));
$this->metadata->expects($this->any())->method('getFieldNames')->will($this->returnValue(array('lastModified')));
$this->metadata->expects($this->any())->method('getFieldMapping')->with($this->equalTo('lastModified'))->will($this->returnValue(array('property' => 'jcr:lastModified')));
$this->metadata->expects($this->any())->method('getFieldValue')->with($this->equalTo($this), $this->equalTo('lastModified'))->will($this->returnValue(new \DateTime('2016-07-06', new \DateTimeZone('Europe/Berlin'))));
return new LastModifiedGuesser($this->registry);
}
示例3: setUp
protected function setUp()
{
if (!interface_exists('Doctrine\\Common\\Persistence\\ManagerRegistry')) {
$this->markTestSkipped('Doctrine Common is not present');
}
if (!class_exists('Doctrine\\ODM\\PHPCR\\DocumentManager')) {
$this->markTestSkipped('Doctrine PHPCR is not present');
}
$this->registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
$this->manager = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
$this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->manager));
$this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository', array('customQueryBuilderCreator', 'createQueryBuilder', 'find', 'findAll', 'findBy', 'findOneBy', 'getClassName'));
$this->manager->expects($this->any())->method('getRepository')->with($this->objectClass)->will($this->returnValue($this->repository));
}
示例4: testAvailableTranslations
/**
* URL without locale, set available translations.
*/
public function testAvailableTranslations()
{
$this->routeMock->expects($this->once())->method('getId')->will($this->returnValue('/cms/simple/something'));
$this->dmMock->expects($this->once())->method('isDocumentTranslatable')->with($this->routeMock)->will($this->returnValue(true));
$this->dmMock->expects($this->once())->method('getLocalesFor')->with($this->routeMock, true)->will($this->returnValue(array('en', 'de', 'fr')));
$this->routeMock->expects($this->once())->method('setRequirement')->with('_locale', 'en|de|fr');
$this->listener->setUpdateAvailableTranslations(true);
$args = new LifecycleEventArgs($this->routeMock, $this->dmMock);
$this->listener->postLoad($args);
}
示例5: testRootEdgeCase
public function testRootEdgeCase()
{
$this->buildMocks('/');
$this->managerRegistry->expects($this->any())->method('getManagerForClass')->with(get_class($this->object))->will($this->returnValue($this->documentManager));
$this->documentManager->expects($this->any())->method('getNodeForDocument')->with($this->object)->willReturn($this->node);
$this->node->expects($this->any())->method('getDepth')->will($this->returnValue(4));
$urlInformation = new UrlInformation();
$this->guesser->guessValues($urlInformation, $this->object, 'default');
$this->assertEquals(3, $urlInformation->getDepth());
}
示例6: testExpandClassName
/**
* @dataProvider provideExpandClassName
*/
public function testExpandClassName($className, $fqClassName, $isAlias)
{
if ($isAlias) {
$this->dm->expects($this->once())->method('getClassMetadata')->with($className)->will($this->returnValue($this->metadata));
$this->metadata->expects($this->once())->method('getName')->will($this->returnValue($fqClassName));
}
$refl = new \ReflectionClass($this->mapper);
$method = $refl->getMethod('expandClassName');
$method->setAccessible(true);
$res = $method->invoke($this->mapper, $this->dm, $className);
$this->assertEquals($fqClassName, $res);
}
示例7: testChangingDocumentManager
/**
* Use getRouteByName() with two different document managers.
* The two document managers will return different route objects when searching for the same path.
*/
public function testChangingDocumentManager()
{
$this->routeMock->expects($this->any())->method('getPath')->will($this->returnValue('/cms/routes/test-route'));
$this->route2Mock->expects($this->any())->method('getPath')->will($this->returnValue('/cms/routes/new-route'));
$this->dmMock->expects($this->any())->method('find')->with(null, '/cms/routes/test-route')->will($this->returnValue($this->routeMock));
$this->dm2Mock->expects($this->any())->method('find')->with(null, '/cms/routes/test-route')->will($this->returnValue($this->route2Mock));
$objectManagers = array('default' => $this->dmMock, 'new_manager' => $this->dm2Mock);
$this->managerRegistryMock = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
$this->managerRegistryMock->expects($this->any())->method('getManager')->will($this->returnCallback(function ($name) use($objectManagers) {
return $objectManagers[$name];
}));
$this->candidatesMock->expects($this->any())->method('isCandidate')->will($this->returnValue(true));
$routeProvider = new RouteProvider($this->managerRegistryMock, $this->candidatesMock);
$routeProvider->setManagerName('default');
$foundRoute = $routeProvider->getRouteByName('/cms/routes/test-route');
$this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $foundRoute);
$this->assertEquals('/cms/routes/test-route', $foundRoute->getPath());
$routeProvider->setManagerName('new_manager');
$newFoundRoute = $routeProvider->getRouteByName('/cms/routes/test-route');
$this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $newFoundRoute);
$this->assertEquals('/cms/routes/new-route', $newFoundRoute->getPath());
}