public function testGetters() { $check = $this->getMock(CheckInterface::class); $check->expects($this->any())->method('getName')->will($this->returnValue('Some Check')); $failure = new FunctionRequirementsFailure($check, ['function' => 'file', 'line' => 3], ['explode']); $this->assertEquals(['function' => 'file', 'line' => 3], $failure->getBannedFunctions()); $this->assertEquals(['explode'], $failure->getMissingFunctions()); $this->assertSame('Some Check', $failure->getCheckName()); }
/** * Print a list of the missing, required functions & print a list of used but banned functions. * * @param ResultsRenderer $renderer * @return string */ public function render(ResultsRenderer $renderer) { $output = ''; if (count($bannedFunctions = $this->result->getBannedFunctions())) { $output .= sprintf(" %s\n%s\n", $renderer->style("Some functions were used which should not be used in this exercise", ['bold', 'underline', 'yellow']), implode("\n", array_map(function (array $call) { return sprintf(' %s on line %s', $call['function'], $call['line']); }, $bannedFunctions))); } if (count($missingFunctions = $this->result->getMissingFunctions())) { $output .= sprintf(" %s\n%s\n", $renderer->style("Some function requirements were missing. You should use the functions", ['bold', 'underline', 'yellow']), implode("\n", array_map(function ($function) { return sprintf(' %s', $function); }, $missingFunctions))); } return $output; }