コード例 #1
0
 /**
  * @expectedException \Dunglas\ApiBundle\Exception\InvalidArgumentException
  * @expectedExceptionMessage Unable to generate an IRI for "Foo".
  */
 public function testGetIriFromResourceRouteNotFound()
 {
     $resourceCollection = $this->prophesize('Dunglas\\ApiBundle\\Api\\ResourceCollectionInterface')->reveal();
     $classMetadataFactory = $this->prophesize('Dunglas\\ApiBundle\\Mapping\\Factory\\ClassMetadataFactoryInterface')->reveal();
     $propertyAccessor = $this->prophesize('Symfony\\Component\\PropertyAccess\\PropertyAccessorInterface')->reveal();
     $dataProvider = $this->prophesize('Dunglas\\ApiBundle\\Model\\DataProviderInterface')->reveal();
     $routerProphecy = $this->prophesize('Symfony\\Component\\Routing\\RouterInterface');
     $routerProphecy->generate(null, [], RouterInterface::ABSOLUTE_PATH)->willThrow('Symfony\\Component\\Routing\\Exception\\RouteNotFoundException')->shouldBeCalled();
     $router = $routerProphecy->reveal();
     $iriConverter = new IriConverter($resourceCollection, $dataProvider, $classMetadataFactory, $router, $propertyAccessor);
     $resourceProphecy = $this->prophesize('Dunglas\\ApiBundle\\Api\\ResourceInterface');
     $resourceProphecy->getShortName()->willReturn('Foo')->shouldBeCalled();
     $resourceProphecy->getCollectionOperations()->willReturn([])->shouldBeCalled();
     $resource = $resourceProphecy->reveal();
     $iriConverter->getIriFromResource($resource);
 }