Beispiel #1
0
 public function load(\Doctrine\Common\Persistence\ObjectManager $manager)
 {
     $group1 = new Group();
     $group1->setTitle('World news');
     $group1->setDescription('What is going on in the domestically and abroad.');
     $group1->setTags('symfony2, php, paradise, high five');
     $group1->setCreated(new \DateTime());
     $group1->setUpdated($group1->getCreated());
     $group1->setUser($manager->merge($this->getReference('user-1')));
     $manager->persist($group1);
     $group2 = new Group();
     $group2->setTitle('Sports');
     $group2->setDescription('Discussions about different sport events.');
     $group2->setTags('symfony2, php, paradise, high five');
     $group2->setCreated(new \DateTime());
     $group2->setUpdated($group2->getCreated());
     $group2->setUser($manager->merge($this->getReference('user-2')));
     $manager->persist($group2);
     $group3 = new Group();
     $group3->setTitle('IT and computer science');
     $group3->setDescription('Everythign related to application development, IT and computers.');
     $group3->setTags('symfony2, php, paradise, high five');
     $group3->setCreated(new \DateTime());
     $group3->setUpdated($group3->getCreated());
     $group3->setUser($manager->merge($this->getReference('user-3')));
     $manager->persist($group3);
     $group4 = new Group();
     $group4->setTitle('Secret group');
     $group4->setDescription('Top secret. Your eyes only.');
     $group4->setTags('paradise, comm');
     $group4->setCreated(new \DateTime());
     $group4->setUpdated($group4->getCreated());
     $group4->setIsPublic(0);
     $group4->setUser($manager->merge($this->getReference('user-3')));
     $manager->persist($group4);
     $manager->flush();
     $this->addReference('group-1', $group1);
     $this->addReference('group-2', $group2);
     $this->addReference('group-3', $group3);
     $this->addReference('group-4', $group4);
 }
Beispiel #2
0
 /**
  * @param Group $group
  *
  * @return Notification
  */
 public function setGroup(Group $group)
 {
     if ($this->group !== $group) {
         $this->group = $group;
         $this->group->addNotification($this);
     }
     return $this;
 }
Beispiel #3
0
 /**
  * @param Group $group
  * @param array $processedTags
  * @return array
  */
 private function getGroupTweets(Group $group, array $processedTags)
 {
     $settings = $this->getTwitterApiSettings();
     $twitterService = $this->getTwitterService();
     $groupTweets = array();
     if ($group->getTags()) {
         $groupTweets = $twitterService->getTweetsByHashKeys($processedTags, $settings);
     }
     return $groupTweets;
 }
Beispiel #4
0
 /**
  * @test
  *
  * @group entity
  * @group group-entity
  */
 public function testSettingDescription()
 {
     $group = new Group();
     $group->setDescription("This is a description");
     $this->assertEquals('This is a description', $group->getDescription());
     $group->setDescription("This is a description", 7);
     $this->assertEquals('This is', $group->getDescription(7));
 }
Beispiel #5
0
 /**
  * @param  Group $group
  * @param  User  $user
  * @return Group
  */
 public function modifyGroup(Group $group, User $user = null)
 {
     if (!$user) {
         $user = $this->security->getToken()->getUser();
     }
     $group->setUser($user);
     $this->em->persist($group);
     $this->em->flush();
     return $group;
 }
Beispiel #6
0
 /**
  * @test
  *
  * @group entity
  * @group post-entity
  */
 public function testSettingGroupToAPost()
 {
     $post = new Post();
     $this->assertEquals(sizeof($post->getGroup()), 0, "Initially there are no group in post");
     $group = new Group();
     $group->setTitle("This is a test group");
     $post->setGroup($group);
     $this->assertEquals($post->getGroup()->getTitle(), "This is a test group");
     $this->assertEquals(sizeof($post->getGroup()), 1, "There should be one group in a post");
 }