/** * @dataProvider preSetData */ public function testPrePersistUser($token, $securityConfig, $expect) { $entity = new Entity(); $this->securityContext->expects($this->once())->method('getToken')->will($this->returnValue($token)); $args = new LifecycleEventArgs($entity, $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager')); $this->configProvider->expects($this->once())->method('hasConfig')->will($this->returnValue(true)); $this->configProvider->expects($this->once())->method('getConfig')->will($this->returnValue($securityConfig)); $this->listener->prePersist($args); if (isset($expect['owner'])) { $this->assertEquals($expect['owner'], $entity->getOwner()); } else { $this->assertNull($entity->getOwner()); } if (isset($expect['organization'])) { $this->assertEquals($expect['organization'], $entity->getOrganization()); } else { $this->assertNull($entity->getOrganization()); } }
public function testPrePersistUser() { $this->config->expects($this->once())->method('get')->with('owner_type')->will($this->returnValue(OwnershipType::OWNER_TYPE_USER)); $this->listener->prePersist($this->listenerArguments); $this->assertEquals($this->user, $this->entity->getOwner()); }