File tree Expand file tree Collapse file tree 4 files changed +98
-9
lines changed Expand file tree Collapse file tree 4 files changed +98
-9
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <phpunit backupGlobals =" false"
3+ backupStaticAttributes =" false"
4+ bootstrap =" vendor/autoload.php"
5+ colors =" true"
6+ convertErrorsToExceptions =" true"
7+ convertNoticesToExceptions =" true"
8+ convertWarningsToExceptions =" true"
9+ processIsolation =" false"
10+ stopOnFailure =" false"
11+ >
12+ <testsuites >
13+ <testsuite name =" Package Test Suite" >
14+ <directory suffix =" .php" >./tests/</directory >
15+ </testsuite >
16+ </testsuites >
17+ </phpunit >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PhpcsDiff \Tests \Filter \Rule ;
4+
5+ use PhpcsDiff \Filter \Rule \Exception \InvalidArgumentException ;
6+ use PhpcsDiff \Filter \Rule \Exception \RuntimeException ;
7+ use PhpcsDiff \Filter \Rule \FileRule ;
8+ use PhpcsDiff \Tests \TestBase ;
9+
10+ class FileRuleTest extends TestBase
11+ {
12+ /**
13+ * @covers FileRule::__invoke
14+ */
15+ public function testInvoke ()
16+ {
17+ $ rule = new FileRule ();
18+
19+ $ this ->assertException (InvalidArgumentException::class, function () use ($ rule ) {
20+ $ rule (null );
21+ });
22+
23+ $ this ->assertException (RuntimeException::class, function () use ($ rule ) {
24+ $ rule ('' );
25+ });
26+
27+ mkdir ('test ' );
28+
29+ $ this ->assertException (RuntimeException::class, function () use ($ rule ) {
30+ $ rule ('test ' );
31+ });
32+
33+ rmdir ('test ' );
34+
35+
36+
37+ //
38+ // $handle = fopen('test', 'wb');
39+ //
40+ // $this->assertException(RuntimeException::class, function() use ($rule) {
41+ // $rule('');
42+ // });
43+ //
44+ // fclose($handle);
45+ }
46+
47+ /**
48+ * @expectedException InvalidArgumentException
49+ * @expectedExceptionMessage The data argument provided is not a string.
50+ * @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
51+ */
52+ public function testNonString ()
53+ {
54+ $ rule = new FileRule ();
55+ $ rule (null );
56+ }
57+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PhpcsDiff \Tests ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+
7+ abstract class TestBase extends TestCase
8+ {
9+ /**
10+ * @param string $expectClass
11+ * @param callable $callback
12+ */
13+ protected function assertException ($ expectClass , callable $ callback )
14+ {
15+ try {
16+ $ callback ();
17+ } catch (\Throwable $ exception ) {
18+ $ this ->assertInstanceOf ($ expectClass , $ exception , 'An invalid exception was thrown ' );
19+ return ;
20+ }
21+
22+ $ this ->fail ('No exception was thrown ' );
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments