/** @test */ public function should_test_equality() { $one = new Admin($this->id, $this->email, $this->username); $two = new Admin($this->id, $this->email, $this->username); $three = new Admin(UserId::generate(), new Email('*****@*****.**'), new Username('other')); $this->assertTrue($one->equals($two)); $this->assertFalse($one->equals($three)); }
/** * Find a User by their id * * @param string $id * @return User */ private function findUserById($id) { $user = $this->users->userById(UserId::fromString($id)); if ($user) { return $user; } throw new ValueNotFoundException("{$id} is not a valid user id"); }
/** * Load the fixtures * * @param ObjectManager $manager * @return void */ public function load(ObjectManager $manager) { $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'); $post = new Post(PostId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'), $user, $thread, 'Hello world.'); $manager->persist($post); $manager->flush(); }
/** @test */ public function should_register_new_user() { $this->repository->shouldReceive('userOfEmail')->once()->andReturn(null); $this->repository->shouldReceive('userOfUsername')->once()->andReturn(null); $this->repository->shouldReceive('nextIdentity')->once()->andReturn(UserId::generate()); $this->repository->shouldReceive('add')->once(); $user = $this->service->register('*****@*****.**', 'username', 'password'); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user); }
/** * Load the User fixtures * * @param ObjectManager $manager * @return void */ public function load(ObjectManager $manager) { $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $email = new Email('*****@*****.**'); $username = new Username('username'); $password = new HashedPassword('qwerty'); $user = User::register($id, $email, $username, $password); $manager->persist($user); $manager->flush(); }
/** @test */ public function should_create_new_group() { $this->groups->shouldReceive('groupOfName')->once()->andReturn(null); $this->groups->shouldReceive('add')->once()->andReturn(null); $this->user->shouldReceive('id')->once()->andReturn(UserId::generate()); $this->user->shouldReceive('email')->once()->andReturn(new Email('*****@*****.**')); $this->user->shouldReceive('username')->once()->andReturn(new Username('username')); $group = $this->service->create($this->user, 'Cribbb'); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group); $this->assertEquals('Cribbb', $group->name()); $this->assertEquals(1, $group->admins()->count()); }
/** @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_user() { $id = UserId::generate(); $email = new Email('*****@*****.**'); $username = new Username('username'); $password = new HashedPassword('qwerty'); $this->repository->add(User::register($id, $email, $username, $password)); $this->em->clear(); $user = $this->repository->userOfUsername(new Username('username')); $this->assertEquals($id, $user->id()); $this->assertEquals($email, $user->email()); $this->assertEquals($username, $user->username()); }
public function setUp() { $id = UserId::generate(); $email = new Email('*****@*****.**'); $username = new Username('username'); $password = new HashedPassword('qwerty123'); $this->user = User::register($id, $email, $username, $password); $this->fixture = ['id' => ReminderId::generate(), 'code' => ReminderCode::generate(), 'email' => new Email('*****@*****.**')]; $this->users = m::mock('Cribbb\\Domain\\Model\\Identity\\UserRepository'); $this->reminders = m::mock('Cribbb\\Domain\\Model\\Identity\\ReminderRepository'); $this->hasher = m::mock('Cribbb\\Domain\\Services\\Identity\\HashingService'); $this->service = new ReminderService($this->reminders, $this->users, $this->hasher); }
/** @test */ public function should_return_user_id_as_string() { $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $id->toString()); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', (string) $id); }
public function setUp() { $this->user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('password')); }
/** * Set the User's id * * @param UserId $id * @return void */ private function setId(UserId $id) { $this->id = $id->toString(); }
public function setUp() { $this->user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('password')); $this->thread = new Thread(ThreadId::generate(), new Group(GroupId::generate(), 'Cribbb'), 'Hello World'); }
/** @test */ public function should_become_an_admin_of_a_group() { $user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('zuck'), new HashedPassword('facemash')); $group = new Group(GroupId::generate(), 'Porcellian'); $this->assertEquals(0, $group->admins()->count()); $this->assertEquals(0, $user->adminOf()->count()); $user->addAsAdminOf($group); $this->assertEquals(1, $group->admins()->count()); $this->assertEquals(1, $user->adminOf()->count()); }
/** * Find a user by their id * * @param UserId $id * @return User */ public function userOfId(UserId $id) { return $this->em->getRepository($this->class)->findOneBy(['id' => $id->toString()]); }