/** @test */ public function should_find_thread_by_id() { $this->executor->execute($this->loader->getFixtures()); $thread = $this->repository->threadOfId(ThreadId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc')); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Thread', $thread); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $thread->id()); }
/** * Find a Thread by its id * * @param string $id * @return Thread */ private function findThreadById($id) { $thread = $this->threads->threadById(ThreadId::fromString($id)); if ($thread) { return $thread; } throw new ValueNotFoundException("{$id} is not a valid thread id"); }
/** * Load the fixtures * * @param ObjectManager $manager * @return void */ public function load(ObjectManager $manager) { $group = new Group(GroupId::generate(), 'Cribbb'); $id = ThreadId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $thread = new Thread($id, $group, 'Hello World'); $manager->persist($thread); $manager->flush(); }
/** @test */ public function should_return_thread_id_as_string() { $id = ThreadId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $id->toString()); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', (string) $id); }
/** * Get the id * * @return ThreadId */ public function id() { return ThreadId::fromString($this->id); }