Doctrine\Tests\ODM\PHPCR\Query\Builder\ConverterPhpcrTest::setUp PHP Метод

setUp() публичный Метод

public setUp ( )
    public function setUp()
    {
        $me = $this;
        // note: this "factory" seems unnecessary in current jackalope
        //       implementation
        $this->qomfFactory = $this->getMockBuilder('Jackalope\\FactoryInterface')->getMock();
        $this->qomf = new QueryObjectModelFactory($this->qomfFactory);
        $mdf = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock();
        $mdf->expects($this->any())->method('getMetadataFor')->will($this->returnCallback(function ($documentFqn) use($me) {
            $meta = $me->getMockBuilder('Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
            if ($documentFqn == '_document_not_mapped_') {
                return $meta;
            }
            $meta->expects($me->any())->method('hasField')->will($me->returnValue(true));
            $meta->expects($me->any())->method('getFieldMapping')->will($me->returnCallback(function ($name) {
                $res = array('fieldName' => $name, 'property' => $name . '_phpcr', 'type' => 'String');
                return $res;
            }));
            $meta->expects($me->any())->method('getNodeType')->will($me->returnValue('nt:unstructured'));
            $meta->expects($me->any())->method('getName')->will($me->returnValue($documentFqn));
            $meta->expects($me->any())->method('hasAssociation')->will($me->returnCallback(function ($field) {
                if ($field === 'associationfield') {
                    return true;
                }
                return false;
            }));
            $meta->nodename = 'nodenameProperty';
            $meta->name = 'MyClassName';
            return $meta;
        }));
        $dm = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
        $dm->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($mdf));
        $dm->expects($this->any())->method('getLocaleChooserStrategy')->will($this->throwException(new InvalidArgumentException('')));
        $this->parentNode = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\Query\\Builder\\AbstractNode')->disableOriginalConstructor()->getMock();
        $this->converter = new ConverterPhpcr($dm, $this->qomf);
        $this->qb = new QueryBuilder();
        $this->qb->setConverter($this->converter);
    }