5
5
use PhpSchool \PhpWorkshop \CodePatcher ;
6
6
use PhpSchool \PhpWorkshop \Event \Event ;
7
7
use PhpSchool \PhpWorkshop \Exercise \ExerciseInterface ;
8
+ use PhpSchool \PhpWorkshop \Input \Input ;
8
9
use PhpSchool \PhpWorkshop \Listener \CodePatchListener ;
9
10
use PHPUnit_Framework_TestCase ;
10
11
use RuntimeException ;
@@ -44,11 +45,11 @@ public function setUp()
44
45
45
46
public function testRevertThrowsExceptionIfPatchNotPreviouslyCalled ()
46
47
{
47
- $ fileName = $ this ->file ;
48
+ $ input = new Input ( ' app ' , [ ' program ' => $ this ->file ]) ;
48
49
$ exercise = $ this ->createMock (ExerciseInterface::class);
49
50
50
51
$ listener = new CodePatchListener ($ this ->codePatcher );
51
- $ event = new Event ('event ' , compact ('exercise ' , 'fileName ' ));
52
+ $ event = new Event ('event ' , compact ('exercise ' , 'input ' ));
52
53
53
54
$ this ->expectException (RuntimeException::class);
54
55
$ this ->expectExceptionMessage ('Can only revert previously patched code ' );
@@ -59,7 +60,7 @@ public function testPatchUpdatesCode()
59
60
{
60
61
file_put_contents ($ this ->file , 'ORIGINAL CONTENT ' );
61
62
62
- $ fileName = $ this ->file ;
63
+ $ input = new Input ( ' app ' , [ ' program ' => $ this ->file ]) ;
63
64
$ exercise = $ this ->createMock (ExerciseInterface::class);
64
65
65
66
$ this ->codePatcher
@@ -69,7 +70,7 @@ public function testPatchUpdatesCode()
69
70
->will ($ this ->returnValue ('MODIFIED CONTENT ' ));
70
71
71
72
$ listener = new CodePatchListener ($ this ->codePatcher );
72
- $ event = new Event ('event ' , compact ('exercise ' , 'fileName ' ));
73
+ $ event = new Event ('event ' , compact ('exercise ' , 'input ' ));
73
74
$ listener ->patch ($ event );
74
75
75
76
$ this ->assertStringEqualsFile ($ this ->file , 'MODIFIED CONTENT ' );
@@ -79,7 +80,7 @@ public function testRevertAfterPatch()
79
80
{
80
81
file_put_contents ($ this ->file , 'ORIGINAL CONTENT ' );
81
82
82
- $ fileName = $ this ->file ;
83
+ $ input = new Input ( ' app ' , [ ' program ' => $ this ->file ]) ;
83
84
$ exercise = $ this ->createMock (ExerciseInterface::class);
84
85
85
86
$ this ->codePatcher
@@ -89,7 +90,7 @@ public function testRevertAfterPatch()
89
90
->will ($ this ->returnValue ('MODIFIED CONTENT ' ));
90
91
91
92
$ listener = new CodePatchListener ($ this ->codePatcher );
92
- $ event = new Event ('event ' , compact ('exercise ' , 'fileName ' ));
93
+ $ event = new Event ('event ' , compact ('exercise ' , 'input ' ));
93
94
$ listener ->patch ($ event );
94
95
$ listener ->revert ($ event );
95
96
0 commit comments