/** @test */
 public function should_add_new_group()
 {
     $this->repository->add(new Group(GroupId::generate(), 'Cribbb'));
     $this->em->clear();
     $group = $this->repository->groupOfName('Cribbb');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\GroupId', $group->id());
     $this->assertEquals('Cribbb', $group->name());
     $this->assertEquals('cribbb', $group->slug());
 }
 /** @test */
 public function should_add_new_thread()
 {
     $group = new Group(GroupId::generate(), 'Cribbb');
     $id = ThreadId::generate();
     $thread = new Thread($id, $group, 'Hello World');
     $this->repository->add($thread);
     $this->em->clear();
     $thread = $this->repository->threadOfId($id);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\ThreadId', $thread->id());
     $this->assertEquals('hello-world', $thread->slug());
 }
 public function createTagCollection()
 {
     $tags = new ArrayCollection();
     $tags->add(new Tag("foo"));
     $tags->add(new Tag("bar"));
     foreach ($tags as $tag) {
         $this->em->persist($tag);
     }
     $this->em->flush();
     $this->em->clear();
     return $tags;
 }
 /** @test */
 public function should_add_new_post()
 {
     $user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('qwerty'));
     $group = new Group(GroupId::generate(), 'Cribbb');
     $thread = new Thread(ThreadId::generate(), $group, 'Hello World');
     $id = PostId::generate();
     $post = new Post($id, $user, $thread, 'Hello world');
     $this->repository->add($post);
     $this->em->clear();
     $post = $this->repository->postOfId($id);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\PostId', $post->id());
     $this->assertEquals('hello-world', $post->slug());
 }
 /** @test */
 public function should_add_new_reminder()
 {
     $id = ReminderId::generate();
     $code = ReminderCode::fromNative('new');
     $email = new Email('*****@*****.**');
     $reminder = new Reminder($id, $email, $code);
     $this->repository->add($reminder);
     $this->em->clear();
     $reminder = $this->repository->findReminderByEmailAndCode($email, $code);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\Reminder', $reminder);
     $this->assertEquals($code, $reminder->code());
     $this->assertEquals($email, $reminder->email());
 }
 public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/_files');
     $config->setProxyNamespace('DoctrineExtensions\\LargeCollections\\Proxies');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     #$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $this->em = \Doctrine\ORM\EntityManager::create($conn, $config);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $schemaTool->createSchema(array($this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Article'), $this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Tag'), $this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Comment')));
     $article = new Article();
     $tag1 = new Tag();
     $tag2 = new Tag();
     $comment1 = new Comment();
     $comment2 = new Comment();
     $article->addComment($comment1);
     $article->addComment($comment2);
     $article->addTag($tag1);
     $article->addTag($tag2);
     $this->em->persist($article);
     $this->em->persist($tag1);
     $this->em->persist($tag2);
     $this->em->persist($comment1);
     $this->em->persist($comment2);
     $this->em->flush();
     $this->articleId = $article->id();
     $this->em->clear();
 }
 /** @test */
 public function should_update_existing_user()
 {
     $this->executor->execute($this->loader->getFixtures());
     $user = $this->repository->userOfUsername(new Username('username'));
     $username = new Username('new_username');
     $user->updateUsername($username);
     $this->repository->update($user);
     $this->em->clear();
     $user = $this->repository->userOfUsername($username);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
     $this->assertEquals($username, $user->username());
 }
 protected function createArticleFixtures()
 {
     $articles = new ArrayCollection();
     $articles->add(new Article('foo', 'toto'));
     $articles->add(new Article('bar', 'toto'));
     $articles->add(new Article('bar', 'titi'));
     $articles->add(new Article('foo', 'titi'));
     $articles->add(new Article('barfoo', 'tata'));
     foreach ($articles as $article) {
         $this->em->persist($article);
     }
     $this->em->flush();
     $this->em->clear();
     return $articles;
 }
 /**
  * Clears the repository, causing all managed entities to become detached.
  */
 public function clear()
 {
     $this->_em->clear($this->_class->rootEntityName);
 }