Exemplo n.º 1
0
 /**
  * Test ExtRefTransformer::reverseTransform() with valid url
  *
  * @return string
  */
 public function testReverseTransformValid()
 {
     $extref = ExtReference::create('ref', 'id');
     $url = 'extref-url';
     $this->converter->expects($this->once())->method('getExtReference')->with($url)->willReturn($extref);
     $this->assertEquals($extref, $this->transformer->reverseTransform($url));
 }
Exemplo n.º 2
0
 /**
  * Test ExtReferenceHandler::deserializeExtReferenceFromJson()
  *
  * @return void
  */
 public function testDeserializeExtReferenceFromJson()
 {
     $type = [__LINE__];
     $context = DeserializationContext::create();
     $url = __FUNCTION__;
     $extref = ExtReference::create(__METHOD__, __FILE__);
     $this->converter->expects($this->once())->method('getExtReference')->with($url)->willReturn($extref);
     $this->deserializationVisitor->expects($this->once())->method('visitString')->with($url, $type, $context)->willReturn($url);
     $handler = new ExtReferenceHandler($this->converter);
     $this->assertEquals($extref, $handler->deserializeExtReferenceFromJson($this->deserializationVisitor, $url, $type, $context));
 }
 /**
  * Test ExtReferenceSearchListener::onVisitNode() with context
  *
  * @return void
  */
 public function testOnVisitNodeWithContext()
 {
     $extrefMapping = ['route.id' => ['array.0.field.$ref']];
     $extrefUrl = 'extref.url';
     $extrefValue = ExtReference::create('Ref', 'id');
     $dbRefValue = \MongoDBRef::create($extrefValue->getRef(), $extrefValue->getId());
     $this->requestAttrs->expects($this->once())->method('get')->with('_route')->willReturn('route.id');
     $this->converter->expects($this->once())->method('getExtReference')->with($extrefUrl)->willReturn($extrefValue);
     $node = new EqNode('field.$ref', $extrefUrl);
     $context = new \SplStack();
     $context->push(new ElemMatchNode('array', $node));
     $builder = $this->getMockBuilder('Doctrine\\ODM\\MongoDB\\Query\\Builder')->disableOriginalConstructor()->getMock();
     $event = new VisitNodeEvent($node, $builder, $context);
     $listener = $this->createListener($extrefMapping);
     $listener->onVisitNode($event);
     $this->assertNotSame($node, $event->getNode());
     $this->assertSame($builder, $event->getBuilder());
     $this->assertEquals(new EqNode('field.$ref', $dbRefValue), $event->getNode());
 }