Passed
Push — master ( 1a0ddb...73af58 )
by Kyle
47s queued 10s
created

test/php/PHPMD/Renderer/CheckStyleRendererTest.php (4 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This file is part of PHP Mess Detector.
4
 *
5
 * Copyright (c) Manuel Pichler <[email protected]>.
6
 * All rights reserved.
7
 *
8
 * Licensed under BSD License
9
 * For full copyright and license information, please see the LICENSE file.
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @author Manuel Pichler <[email protected]>
13
 * @copyright Manuel Pichler. All rights reserved.
14
 * @license https://opensource.org/licenses/bsd-license.php BSD License
15
 * @link http://phpmd.org/
16
 */
17
18
namespace PHPMD\Renderer;
19
20
use PHPMD\AbstractTest;
21
use PHPMD\ProcessingError;
22
use PHPMD\Stubs\WriterStub;
23
24
/**
25
 * Test case for the xml renderer implementation.
26
 *
27
 * @covers \PHPMD\Renderer\XMLRenderer
28
 */
29 View Code Duplication
class CheckStyleRendererTest extends AbstractTest
30
{
31
    /**
32
     * testRendererCreatesExpectedNumberOfXmlElements
33
     *
34
     * @return void
35
     */
36
    public function testRendererCreatesExpectedNumberOfXmlElements()
37
    {
38
        // Create a writer instance.
39
        $writer = new WriterStub();
40
41
        $violations = array(
42
            $this->getRuleViolationMock('/bar.php'),
43
            $this->getRuleViolationMock('/foo.php'),
44
            $this->getRuleViolationMock('/foo.php', 23, 42, null, 'foo <?php bar'),
45
        );
46
47
        $report = $this->getReportWithNoViolation();
48
        $report->expects($this->once())
0 ignored issues
show
The method expects() does not seem to exist on object<PHPMD\Report>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
            ->method('getRuleViolations')
50
            ->will($this->returnValue(new \ArrayIterator($violations)));
51
        $report->expects($this->once())
0 ignored issues
show
The method expects() does not seem to exist on object<PHPMD\Report>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
            ->method('getErrors')
53
            ->will($this->returnValue(new \ArrayIterator(array())));
54
55
        $renderer = new XMLRenderer();
56
        $renderer->setWriter($writer);
57
58
        $renderer->start();
59
        $renderer->renderReport($report);
60
        $renderer->end();
61
62
        $this->assertXmlEquals(
63
            $writer->getData(),
64
            'renderer/xml_renderer_expected1.xml'
65
        );
66
    }
67
68
    /**
69
     * testRendererAddsProcessingErrorsToXmlReport
70
     *
71
     * @return void
72
     * @since 1.2.1
73
     */
74
    public function testRendererAddsProcessingErrorsToXmlReport()
75
    {
76
        // Create a writer instance.
77
        $writer = new WriterStub();
78
79
        $processingErrors = array(
80
            new ProcessingError('Failed for file "/tmp/foo.php".'),
81
            new ProcessingError('Failed for file "/tmp/bar.php".'),
82
            new ProcessingError('Failed for file "/tmp/baz.php".'),
83
        );
84
85
        $report = $this->getReportWithNoViolation();
86
        $report->expects($this->once())
0 ignored issues
show
The method expects() does not seem to exist on object<PHPMD\Report>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
87
            ->method('getRuleViolations')
88
            ->will($this->returnValue(new \ArrayIterator(array())));
89
        $report->expects($this->once())
0 ignored issues
show
The method expects() does not seem to exist on object<PHPMD\Report>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
90
            ->method('getErrors')
91
            ->will($this->returnValue(new \ArrayIterator($processingErrors)));
92
93
        $renderer = new XMLRenderer();
94
        $renderer->setWriter($writer);
95
96
        $renderer->start();
97
        $renderer->renderReport($report);
98
        $renderer->end();
99
100
        $this->assertXmlEquals(
101
            $writer->getData(),
102
            'renderer/xml_renderer_processing_errors.xml'
103
        );
104
    }
105
}
106