11<?php
22
3+ namespace unit ;
4+
35use PHPUnit \Framework \Attributes \DataProvider ;
46use PHPUnit \Framework \Attributes \Test ;
57use PHPUnit \Framework \Attributes \TestDox ;
68use PHPUnit \Framework \TestCase ;
79use rcsofttech85 \FileHandler \Exception \CouldNotWriteFileException ;
810use rcsofttech85 \FileHandler \Exception \FileNotFoundException ;
911use rcsofttech85 \FileHandler \FileHandler ;
12+ use TypeError ;
1013
1114class FileHandlerTest extends TestCase
1215{
13-
1416 private FileHandler |null $ fileHandler ;
1517
1618 protected function setUp (): void
@@ -31,7 +33,7 @@ protected function tearDown(): void
3133
3234
3335 #[Test]
34- public function file_successfully_written ()
36+ public function fileSuccessfullyWritten ()
3537 {
3638 $ this ->fileHandler ->open (filename: 'file ' );
3739
@@ -41,15 +43,15 @@ public function file_successfully_written()
4143 }
4244
4345 #[Test]
44- public function should_throw_exception_if_file_is_not_Found ()
46+ public function shouldThrowExceptionIfFileIsNotFound ()
4547 {
4648 $ this ->expectException (FileNotFoundException::class);
4749 $ this ->expectExceptionMessage ('File not found ' );
4850 $ this ->fileHandler ->open (filename: 'unknown ' );
4951 }
5052
5153 #[Test]
52- public function should_throw_exception_if_file_is_not_writable ()
54+ public function shouldThrowExceptionIfFileIsNotWritable ()
5355 {
5456 $ this ->fileHandler ->open (filename: 'file ' , mode: 'r ' );
5557
@@ -59,7 +61,7 @@ public function should_throw_exception_if_file_is_not_writable()
5961 }
6062
6163 #[Test]
62- public function multiple_file_can_be_written_simultaneously ()
64+ public function multipleFileCanBeWrittenSimultaneously ()
6365 {
6466 $ this ->fileHandler ->open (filename: 'file ' );
6567
@@ -76,7 +78,7 @@ public function multiple_file_can_be_written_simultaneously()
7678
7779
7880 #[Test]
79- public function file_is_closed_properly ()
81+ public function fileIsClosedProperly ()
8082 {
8183 $ this ->fileHandler ->open (filename: 'file ' );
8284 $ this ->fileHandler ->write (data: "hello world " );
@@ -87,9 +89,9 @@ public function file_is_closed_properly()
8789 }
8890
8991 #[Test]
90- #[DataProvider('provide_movie_names ' )]
92+ #[DataProvider('provideMovieNames ' )]
9193 #[TestDox('search result with name $keyword exists in file. ' )]
92- public function result_found_for_exact_name_match (string $ keyword )
94+ public function resultFoundForExactNameMatch (string $ keyword )
9395 {
9496 $ isMovieAvailable = $ this ->fileHandler ->open (filename: 'movie.csv ' )->searchInCsvFile (
9597 keyword: $ keyword ,
@@ -99,9 +101,9 @@ public function result_found_for_exact_name_match(string $keyword)
99101 }
100102
101103 #[Test]
102- #[DataProvider('provide_studio_names ' )]
104+ #[DataProvider('provideStudioNames ' )]
103105 #[TestDox('search result with name $keyword exists in file. ' )]
104- public function studio_is_found_for_exact_name_match (string $ keyword )
106+ public function studioIsFoundForExactNameMatch (string $ keyword )
105107 {
106108 $ isStudioFound = $ this ->fileHandler ->open (filename: 'movie.csv ' )->searchInCsvFile (
107109 keyword: $ keyword ,
@@ -111,7 +113,7 @@ public function studio_is_found_for_exact_name_match(string $keyword)
111113 }
112114
113115 #[Test]
114- public function to_array_method_returns_valid_array ()
116+ public function toArrayMethodReturnsValidArray ()
115117 {
116118 $ data = $ this ->fileHandler ->open (filename: 'movie.csv ' )->toArray ();
117119 $ expected = [
@@ -130,7 +132,7 @@ public function to_array_method_returns_valid_array()
130132 }
131133
132134 #[Test]
133- public function search_by_keyword_and_return_array ()
135+ public function searchByKeywordAndReturnArray ()
134136 {
135137 $ expected = [
136138 'Film ' => 'Zack and Miri Make a Porno ' ,
@@ -153,19 +155,18 @@ public function search_by_keyword_and_return_array()
153155 $ this ->assertEquals ($ expected , $ data );
154156 }
155157
156- public static function provide_studio_names (): iterable
158+ public static function provideStudioNames (): iterable
157159 {
158160 yield ["Fox " ];
159161 yield ["Universal " ];
160162 yield ["Warner Bros. " ];
161163 }
162164
163165
164- public static function provide_movie_names (): iterable
166+ public static function provideMovieNames (): iterable
165167 {
166168 yield ["The Ugly Truth " ];
167169 yield ["Leap Year " ];
168170 yield ["Twilight " ];
169171 }
170-
171- }
172+ }
0 commit comments