/** * {@inheritdoc} */ public function write(PolicyViolationReport $report) { if (!$report->hasViolations()) { $this->out->writeln("<info>No policy violations found!</info>"); return; } if ($report->hasMajorViolations()) { $this->out->writeln(sprintf("<error>%d major policy violations found!</error>", count($report->getMajorViolations()))); $this->printViolations($report->getMajorViolations()); } if ($report->hasMinorViolations()) { $this->out->writeln(sprintf("<error>%d minor policy violations found!</error>", count($report->getMinorViolations()))); $this->printViolations($report->getMinorViolations()); } if ($report->hasUndefinedViolations()) { $this->out->writeln(sprintf("<error>%d relations have no policy defined!</error>", count($report->getUndefinedViolations()))); $this->printViolations($report->getUndefinedViolations()); } }
public function testGetUndefinedViolations_withUndefinedViolations_returnsViolations() { // add violations $this->report->undefined($this->violation('test')); $this->report->undefined($this->violation('test')); $this->report->undefined($this->violation('test')); $this->report->undefined($this->violation('foo')); $violations = $this->report->getUndefinedViolations(); $this->assertArrayHasKey('test', $violations); $this->assertArrayHasKey('foo', $violations); $this->assertCount(2, $violations); $this->assertCount(3, $violations['test']); $this->assertCount(1, $violations['foo']); }