1 | <?php |
||
37 | { |
||
38 | private $expectedDocHeader = <<<'DOCHEADER' |
||
39 | /* |
||
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
41 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
42 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
43 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
44 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
46 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
47 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
48 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
49 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
50 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
51 | * |
||
52 | * This software consists of voluntary contributions made by many individuals |
||
53 | * and is licensed under the MIT license. |
||
54 | */ |
||
55 | DOCHEADER; |
||
56 | |||
57 | /** @var Checker */ |
||
58 | private $checker; |
||
59 | |||
60 | /** |
||
61 | * {@inheritDoc} |
||
62 | */ |
||
63 | protected function setUp() : void |
||
64 | { |
||
65 | $this->checker = new Checker('test'); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @test |
||
70 | */ |
||
71 | public function it_should_not_fail_when_cant_find_files_to_validate() : void |
||
72 | { |
||
73 | $fileSystem = vfsStream::setup(); |
||
74 | |||
75 | $outputResource = tmpfile(); |
||
76 | $directory = $fileSystem->path(); |
||
77 | |||
78 | $input = new StringInput($directory); |
||
79 | $output = new StreamOutput($outputResource); |
||
80 | |||
81 | $this->assertSame(0, $this->checker->run($input, $output)); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @test |
||
86 | */ |
||
87 | public function it_should_validate_file() : void |
||
88 | { |
||
89 | $directory = __DIR__ . '/../../assets/CorrectHeader.php'; |
||
90 | $outputResource = tmpfile(); |
||
91 | |||
92 | $input = new StringInput($directory); |
||
93 | $output = new StreamOutput($outputResource); |
||
94 | |||
95 | $this->assertSame(0, $this->checker->run($input, $output)); |
||
96 | } |
||
97 | |||
98 | public function testItShouldFailToValidateMissingHeaderOnFiles() : void |
||
99 | { |
||
100 | $directory = __DIR__ . '/../../assets/MissingHeader.php'; |
||
101 | $outputResource = tmpfile(); |
||
102 | |||
103 | $input = new StringInput($directory); |
||
104 | $output = new StreamOutput($outputResource); |
||
105 | |||
106 | $this->assertSame(1, $this->checker->run($input, $output)); |
||
107 | } |
||
108 | } |
||
109 |