Example #1
0
 public function testBeforeSearchEvent()
 {
     $query = new Query();
     $query->from('testEntity')->andWhere('name', '~', 'string');
     $this->securityFacade->expects($this->once())->method('getOrganizationId')->will($this->returnValue(5));
     $event = new BeforeSearchEvent($query);
     $this->listener->beforeSearchEvent($event);
     $wherePart = $query->getOptions();
     $this->assertCount(2, $wherePart);
     $expexted = ['fieldName' => 'organization', 'condition' => 'in', 'fieldValue' => [5, 0], 'fieldType' => 'integer', 'type' => 'and'];
     $this->assertEquals($expexted, $wherePart[1]);
 }
Example #2
0
 public function testPrepareEntityMapEvent()
 {
     $entity = new CmsArticle();
     $organization = new CmsOrganization();
     $organization->id = 3;
     $entity->setOrganization($organization);
     $data = ['integer' => ['organization' => null]];
     $metadata = new OwnershipMetadata('ORGANIZATION', 'organization', 'organization_id', 'organization', '');
     $this->metadataProvider->expects($this->once())->method('getMetadata')->will($this->returnValue($metadata));
     $event = new PrepareEntityMapEvent($entity, get_class($entity), $data, ['alias' => 'test']);
     $this->listener->prepareEntityMapEvent($event);
     $resultData = $event->getData();
     $this->assertEquals(3, $resultData['integer']['organization']);
 }