/** * Check that a Group name is unique * * @param string $name * @throws ValueIsNotUniqueException * @return void */ private function checkNameIsUnique($name) { $specification = new NameIsUnique($this->groups); if (!$specification->isSatisfiedBy($name)) { throw new ValueIsNotUniqueException("There is already a group called {$name}"); } }
/** @test */ public function should_return_false_when_not_unique() { $this->repository->shouldReceive('groupOfName')->andReturn(['id' => 1]); $this->assertFalse($this->spec->isSatisfiedBy('Cribbb')); }