Exemplo n.º 1
0
 public function testCreateQueryBuilderForCollection()
 {
     $this->classMetadata->expects($this->once())->method('getFieldNames')->will($this->returnValue([]));
     $this->classMetadata->expects($this->once())->method('getAssociationTargetClass')->with($this->identicalTo('translations'))->will($this->returnValue($translationClass = TranslationTest::class));
     $translationClassMetadata = $this->createClassMetadataMock();
     $translationClassMetadata->expects($this->once())->method('getFieldNames')->will($this->returnValue(['locale']));
     $this->documentManager->expects($this->once())->method('getClassMetadata')->with($this->identicalTo($translationClass))->will($this->returnValue($translationClassMetadata));
     $this->documentManager->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock()));
     $queryBuilder->expects($this->once())->method('field')->with($this->identicalTo('translations.locale'))->will($this->returnSelf());
     $this->localeContext->expects($this->once())->method('getLocales')->will($this->returnValue($locales = ['fr']));
     $this->localeContext->expects($this->once())->method('getFallbackLocale')->will($this->returnValue($fallbackLocale = 'en'));
     $queryBuilder->expects($this->once())->method('in')->with($this->identicalTo(array_merge($locales, [$fallbackLocale])))->will($this->returnSelf());
     $this->assertSame($queryBuilder, $this->translatableRepository->createQueryBuilderForCollection());
 }