@@ -25,17 +25,17 @@ class UnzipStepRunnerTest extends PHPUnitTestCase {
25
25
private $ runtime ;
26
26
27
27
/**
28
- * @var UnzipStepRunner $step
28
+ * @var UnzipStepRunner $step_runner
29
29
*/
30
- private $ step ;
30
+ private $ step_runner ;
31
31
32
32
/**
33
33
* @var Filesystem
34
34
*/
35
- private $ file_system ;
35
+ private $ filesystem ;
36
36
37
37
/**
38
- * @var Stub
38
+ * @var ResourceManager $resource_manager resource manager mock
39
39
*/
40
40
private $ resource_manager ;
41
41
@@ -48,51 +48,47 @@ public function before() {
48
48
49
49
$ this ->resource_manager = $ this ->createMock ( ResourceManager::class );
50
50
51
- $ this ->step = new UnzipStepRunner ();
52
- $ this ->step ->setRuntime ( $ this ->runtime );
53
- $ this ->step ->setResourceManager ( $ this ->resource_manager );
51
+ $ this ->step_runner = new UnzipStepRunner ();
52
+ $ this ->step_runner ->setRuntime ( $ this ->runtime );
53
+ $ this ->step_runner ->setResourceManager ( $ this ->resource_manager );
54
54
55
- $ this ->file_system = new Filesystem ();
55
+ $ this ->filesystem = new Filesystem ();
56
56
}
57
57
58
58
/**
59
59
* @after
60
60
*/
61
61
public function after () {
62
- $ this ->file_system ->remove ( $ this ->document_root );
62
+ $ this ->filesystem ->remove ( $ this ->document_root );
63
63
}
64
64
65
- public function test (){
66
- $ this ->assertTrue (true ); // Placeholder until true test are fixed.
65
+ public function testUnzipFileWhenUsingAbsolutePath () {
66
+ $ zip = __DIR__ . '/resources/test_zip.zip ' ;
67
+ $ this ->resource_manager ->method ( 'getStream ' )
68
+ ->willReturn ( fopen ( $ zip , 'rb ' ) );
69
+
70
+ $ step = new UnzipStep ();
71
+ $ step ->setZipFile ( $ zip );
72
+ $ extracted_file_path = $ this ->runtime ->resolvePath ( 'dir/test_zip.txt ' );
73
+ $ step ->setExtractToPath ( Path::getDirectory ( $ extracted_file_path ) );
74
+
75
+ $ this ->step_runner ->run ( $ step , new Tracker () );
76
+
77
+ self ::assertFileEquals ( __DIR__ . '/resources/test_zip.txt ' , $ extracted_file_path );
67
78
}
68
79
69
- // public function testUnzipFileWhenUsingAbsolutePath() {
70
- // $zip = __DIR__ . '/resources/test_zip.zip';
71
- // $this->resource_manager->method( 'getStream' )
72
- // ->willReturn( fopen( $zip, 'rb' ) );
73
- //
74
- // $input = new UnzipStep();
75
- // $input->setZipFile( $zip );
76
- // $extracted_file_path = $this->runtime->resolvePath( 'dir/test_zip.txt' );
77
- // $input->setExtractToPath( Path::getDirectory( $extracted_file_path ) );
78
- //
79
- // $this->step->run( $input, new Tracker() );
80
- //
81
- // $this->assertFileEquals( __DIR__ . '/resources/test_zip.txt', $extracted_file_path );
82
- // }
83
- //
84
- // public function testUnzipFileWhenUsingRelativePath() {
85
- // $zip = __DIR__ . '/resources/test_zip.zip';
86
- // $this->resource_manager->method( 'getStream' )
87
- // ->willReturn( fopen( $zip, 'rb' ) );
88
- //
89
- // $input = new UnzipStep();
90
- // $input->setZipFile( $zip );
91
- // $input->setExtractToPath( 'dir' );
92
- //
93
- // $this->step->run( $input, new Tracker() );
94
- //
95
- // $extracted_file_path = $this->runtime->resolvePath( 'dir/test_zip.txt' );
96
- // $this->assertFileEquals( __DIR__ . '/resources/test_zip.txt', $extracted_file_path );
97
- // }
80
+ public function testUnzipFileWhenUsingRelativePath () {
81
+ $ zip = __DIR__ . '/resources/test_zip.zip ' ;
82
+ $ this ->resource_manager ->method ( 'getStream ' )
83
+ ->willReturn ( fopen ( $ zip , 'rb ' ) );
84
+
85
+ $ input = new UnzipStep ();
86
+ $ input ->setZipFile ( $ zip );
87
+ $ input ->setExtractToPath ( 'dir ' );
88
+
89
+ $ this ->step_runner ->run ( $ input , new Tracker () );
90
+
91
+ $ extracted_file_path = $ this ->runtime ->resolvePath ( 'dir/test_zip.txt ' );
92
+ self ::assertFileEquals ( __DIR__ . '/resources/test_zip.txt ' , $ extracted_file_path );
93
+ }
98
94
}
0 commit comments