Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd83dcd
commit a201947
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
1 <?php declare(strict_types=1); | ||
2 function f() | ||
3 { | ||
- 4 $result = 'result'; | ||
5 | ||
6 return $result; | ||
- 7 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of FOAL. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\FOAL; | ||
|
||
use function file; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\Small; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(FileRenderer::class)] | ||
#[UsesClass(File::class)] | ||
#[Small] | ||
final class FileRendererTest extends TestCase | ||
{ | ||
public function testRendersFileAsString(): void | ||
{ | ||
$this->assertStringEqualsFile( | ||
__DIR__ . '/../expectations/source.txt', | ||
(new FileRenderer)->render($this->file()), | ||
); | ||
} | ||
|
||
private function file(): File | ||
{ | ||
return new File( | ||
file(__DIR__ . '/../fixture/source.php'), | ||
[4, 7], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of FOAL. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\FOAL; | ||
|
||
use function file; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\Small; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(File::class)] | ||
#[Small] | ||
final class FileTest extends TestCase | ||
{ | ||
public function testHasSourceLines(): void | ||
{ | ||
$this->assertSame( | ||
file(__DIR__ . '/../fixture/source.php'), | ||
$this->file()->sourceLines(), | ||
); | ||
} | ||
|
||
public function testLinesEliminatedByOptimizer(): void | ||
{ | ||
$this->assertSame( | ||
[4, 7], | ||
$this->file()->linesEliminatedByOptimizer(), | ||
); | ||
} | ||
|
||
private function file(): File | ||
{ | ||
return new File( | ||
file(__DIR__ . '/../fixture/source.php'), | ||
[4, 7], | ||
); | ||
} | ||
} |