44
55use Base \BaseTest ;
66use PHPUnit \Framework \Attributes \Test ;
7+ use Rcsofttech85 \FileHandler \Exception \FileHandlerException ;
8+ use Rcsofttech85 \FileHandler \Exception \HashException ;
79use Rcsofttech85 \FileHandler \FileHashChecker ;
8- use Symfony \Component \Dotenv \Dotenv ;
910
1011class FileHashCheckerTest extends BaseTest
1112{
@@ -29,10 +30,11 @@ protected function tearDown(): void
2930 public static function setUpBeforeClass (): void
3031 {
3132 parent ::setUpBeforeClass ();
32- $ dotenv = new Dotenv ();
33- $ dotenv ->load ('.env ' );
3433
35- self ::$ file = $ _ENV ['FILE_NAME ' ];
34+ $ file = self ::$ containerBuilder ->getParameter ('STORED_HASH_FILE ' );
35+ if (is_string ($ file )) {
36+ self ::$ file = $ file ;
37+ }
3638 static ::$ files = ['movie.csv ' , 'sample ' ];
3739 }
3840
@@ -41,6 +43,10 @@ public static function tearDownAfterClass(): void
4143 parent ::tearDownAfterClass ();
4244 }
4345
46+
47+ /**
48+ * @throws HashException
49+ */
4450 #[Test]
4551 public function shouldGenerateValidHashForDifferentAlgo (): void
4652 {
@@ -58,6 +64,10 @@ public function shouldGenerateValidHashForDifferentAlgo(): void
5864 $ this ->assertEquals ($ expectedHash , $ actualHash );
5965 }
6066
67+ /**
68+ * @throws HashException
69+ * @throws FileHandlerException
70+ */
6171 #[Test]
6272 public function checkFileIntegrityReturnsTrueIfHashMatch (): void
6373 {
@@ -66,6 +76,10 @@ public function checkFileIntegrityReturnsTrueIfHashMatch(): void
6676 $ this ->assertTrue ($ isVerified );
6777 }
6878
79+ /**
80+ * @throws HashException
81+ * @throws FileHandlerException
82+ */
6983 #[Test]
7084 public function shouldReturnFalseIfFileIsModified (): void
7185 {
@@ -79,6 +93,10 @@ public function shouldReturnFalseIfFileIsModified(): void
7993 file_put_contents ("movie.csv " , $ backup );
8094 }
8195
96+ /**
97+ * @throws HashException
98+ * @throws FileHandlerException
99+ */
82100 #[Test]
83101 public function shouldReturnFalseIfDifferentAlgoIsUsedForVerifyHash (): void
84102 {
0 commit comments