/** * @dataProvider headerCommentTestData * @param string $name * @param string $src * @param string $header * @param string $expected */ public function testHeaderCommentInsertedCorrectly($name, $src, $header, $expected) { $fixer = new LowerHeaderCommentFixer(); $file = $this->getMockBuilder(\SplFileInfo::class)->disableOriginalConstructor()->getMock(); foreach (get_class_methods(\SplFileInfo::class) as $method) { $file->expects($this->never())->method($method); } LowerHeaderCommentFixer::setHeader($header); $actual = $fixer->fix($file, $src); $this->assertSame($expected, $actual, 'HeaderCommentFixer failed with data set ' . $name); $actual = $fixer->fix($file, $actual); $this->assertSame($expected, $actual, 'HeaderCommentFixer changed the output after successful first run with ' . $name); }
/** * @dataProvider testDataProvider * @param string $data * @param string $expected * @param string $set */ public function testConsecutiveFixerCalls($data, $expected, $set) { $header = <<<EOF This file is (c) 2016 by Cyberhouse GmbH It is free software; you can redistribute it and/or modify it under the terms of the Apache License 2.0 For the full copyright and license information see <http://www.apache.org/licenses/LICENSE-2.0> EOF; $file = $this->getMockBuilder(\SplFileInfo::class)->disableOriginalConstructor()->getMock(); foreach (get_class_methods(\SplFileInfo::class) as $method) { $file->expects($this->never())->method($method); } LowerHeaderCommentFixer::setHeader($header); $actual = $data; $fixers = [new LowerHeaderCommentFixer(), new NamespaceFirstFixer(), new SingleEmptyLineFixer()]; foreach ($fixers as $fixer) { $actual = $fixer->fix($file, $actual); } $this->assertSame($expected, $actual, 'Unexpected result for data set ' . $set); }