protected function persistActivity($name) { if (!isset($this->defaults['user'])) { $this->defaults['user'] = $this->persistUser('default_user'); } if (!isset($this->defaults['workspace'])) { $workspace = new Workspace(); $workspace->setName('ws-jdoe'); $workspace->setCreator($this->defaults['user']); $workspace->setCode('jdoe-123'); $workspace->setGuid('123'); $this->om->persist($workspace); $this->defaults['workspace'] = $workspace; } if (!isset($this->defaults['activity_type'])) { $type = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('activity'); $this->defaults['activity_type'] = $type; } $node = new ResourceNode(); $node->setName($name); $node->setCreator($this->defaults['user']); $node->setResourceType($this->defaults['activity_type']); $node->setWorkspace($this->defaults['workspace']); $node->setGuid($name); $node->setClass('foo'); $activity = new Activity(); $activity->setName($name); $activity->setDescription('desc'); $activity->setResourceNode($node); $this->om->persist($node); $this->om->persist($activity); return $activity; }
private function createActivity($name) { $user = new User(); $user->setFirstName('John'); $user->setLastName('Doe'); $user->setUsername('jdoe'); $user->setMail('*****@*****.**'); $user->setPassword('123'); $workspace = new Workspace(); $workspace->setName('w1'); $workspace->setCode('abc'); $workspace->setGuid('abc123'); $workspace->setCreator($user); $type = new ResourceType(); $type->setName('activity'); $node = new ResourceNode(); $node->setName($name); $node->setClass('FooClass'); $node->setCreator($user); $node->setResourceType($type); $node->setWorkspace($workspace); $activity = new Activity(); $activity->setResourceNode($node); $activity->setDescription('activity...'); $this->om->persist($user); $this->om->persist($workspace); $this->om->persist($type); $this->om->persist($node); $this->om->persist($activity); return $activity; }