コード例 #1
0
 public function testParseEntry()
 {
     $jsonEntry = '
     {
         "id":"(error)",
         "raw":"Expected \'{a}\' at column {b}, not column {c}.",
         "evidence":"       \\"Niets van deze web site mag worden verveelvoudigd en/of \\n\\" +",
         "line":3,
         "character":8,
         "a":"Niets van deze web site mag worden verveelvoudigd en/of \\n",
         "b":9,
         "c":8,
         "reason":"Expected \'Niets van deze web site mag worden verveelvoudigd en/of \\n\' at column 9, not column 8."
     }';
     $entryObject = json_decode(trim($jsonEntry));
     $parser = new EntryParser();
     $parser->parse($entryObject);
     $this->assertTrue($parser->parse($entryObject));
     $entry = $parser->getEntry();
     $this->assertInstanceOf('webignition\\NodeJslintOutput\\Entry\\Entry', $entry);
     $this->assertEquals('(error)', $entry->getId());
     $this->assertEquals('Expected \'{a}\' at column {b}, not column {c}.', $entry->getRaw());
     $this->assertEquals("       \"Niets van deze web site mag worden verveelvoudigd en/of \n\" +", $entry->getEvidence());
     $this->assertEquals(3, $entry->getLineNumber());
     $this->assertEquals(8, $entry->getColumnNumber());
     $this->assertEquals(array('a' => "Niets van deze web site mag worden verveelvoudigd en/of \n", 'b' => 9, 'c' => 8), $entry->getParameters());
     $this->assertEquals("Expected 'Niets van deze web site mag worden verveelvoudigd en/of \n' at column 9, not column 8.", $entry->getReason());
 }
コード例 #2
0
 /**
  * 
  * @param string $rawOutput
  * @return \webignition\NodeJslintOutput\NodeJslintOutput
  * @throws \webignition\NodeJslintOutput\Exception
  */
 public function parse($rawOutput)
 {
     if (!is_string($rawOutput)) {
         return false;
     }
     $this->rawOutput = trim($rawOutput);
     if ($this->isInputFileNotFoundException()) {
         throw $this->getInputFileNotFoundException();
     }
     if ($this->isIncorrectNodeJsPathException()) {
         throw $this->getIncorrectNodeJsPathException();
     }
     if (!$this->isDecodedOutputFormatCorrect()) {
         throw new NodeJsLintOutputException('Unexpected output; is not a lint result set', NodeJsLintOutputException::CODE_UNEXPECTED_OUTPUT);
     }
     $decodedRawOutput = $this->getDecodedRawOutput();
     $statusLine = $decodedRawOutput[0];
     $entries = $decodedRawOutput[1];
     $this->nodeJsLintOutput = new NodeJslintOutput();
     $this->nodeJsLintOutput->setStatusLine($statusLine);
     if (count($entries) === 0) {
         return $this->nodeJsLintOutput;
     }
     $entryParser = new EntryParser();
     foreach ($entries as $entryObject) {
         if (!is_null($entryObject)) {
             $entryParser->parse($entryObject);
             $this->nodeJsLintOutput->addEntry($entryParser->getEntry());
         }
     }
     return $this->nodeJsLintOutput;
 }
コード例 #3
0
 public function testSerializeSingleEntryExcludeParameters()
 {
     $jsonEntry = '{"id":"(error)","raw":"Expected \'{a}\' at column {b}, not column {c}.","evidence":"evidence content","line":3,"character":8,"a":"a value","b":9,"c":8,"reason":"Expected \'a value\' at column 9, not column 8."}';
     $expectedSerializedEntry = '{"id":"(error)","raw":"Expected \'{a}\' at column {b}, not column {c}.","evidence":"evidence content","line":3,"character":8,"reason":"Expected \'a value\' at column 9, not column 8."}';
     $entryObject = json_decode(trim($jsonEntry));
     $parser = new EntryParser();
     $parser->parse($entryObject);
     $serializer = new EntrySerializer();
     $serializer->setExcludeParameters(true);
     $this->assertEquals($expectedSerializedEntry, $serializer->serialize($parser->getEntry()));
 }