/** * @test * @dataProvider provideInvalidTagName * @param string $name * @param int $errorSize */ public function invalidTagName($name, $errorSize = 1) { $tag = new Tag(); $tag->setName($name); $result = $this->spec->validate($tag); $errors = $result->getErrors(); $this->assertFalse($result->isValid()); $this->assertCount(1, $errors); $this->assertCount($errorSize, $errors["name"]); }
/** * @param Tags $tags * @return SpecResult */ public function validate(Tags $tags) { $spec = new TagSpec(); foreach ($tags as $tag) { /** @var Tag $tag */ $result = $spec->validate($tag); if (!$result->isValid()) { $errors = $result->getErrors(); return new SpecResult(false, ["tags" => $errors["name"]]); } } return new SpecResult(); }