Exemplo n.º 1
0
    /**
     * @test
     */
    public function itShouldGenerateValidXml()
    {
        $this->result->getAssumptions()->shouldBeCalled()->willReturn([['file' => 'MyClass.php', 'line' => 122, 'message' => 'if ($test) {'], ['file' => 'MyClass.php', 'line' => 132, 'message' => '$test ? "Yes" : "No"'], ['file' => 'MyOtherClass.php', 'line' => 12, 'message' => 'if ($test !== false) {']]);
        $this->result->getAssumptionsCount()->shouldBeCalled()->willReturn(3);
        $this->result->getPercentage()->shouldBeCalled()->willReturn(60);
        $this->result->getBoolExpressionsCount()->shouldBeCalled()->willReturn(5);
        $this->xmlOutput->output($this->result->reveal());
        $version = Cli::VERSION;
        $expected = <<<XML
<?xml version="1.0"?>
<phpa version="{$version}" assumptions="3" bool-expressions="5" percentage="60">
    <files>
        <file name="MyClass.php">
            <line number="122" message="if (\$test) {" />
            <line number="132" message="\$test ? &quot;Yes&quot; : &quot;No&quot;" />
        </file>
        <file name="MyOtherClass.php">
            <line number="12" message="if (\$test !== false) {" />
        </file>
    </files>
</phpa>
XML;
        $this->assertXmlStringEqualsXmlString($expected, file_get_contents($this->file));
    }