@@ -20,6 +20,19 @@ public function getPackageProviders($app)
2020 */
2121 public function it_checks_if_used_env_vars_are_defined ()
2222 {
23+ $ envPath = base_path ('.env ' );
24+ file_put_contents ($ envPath , implode ("\n" , [
25+ 'FILLED=value ' ,
26+ 'NOT_FILLED=another ' ,
27+ 'FILLED_WITH_FALSE=false ' ,
28+ 29+ 'DEPENDING_ON_DEFAULT=custom ' ,
30+ 'DEFAULT_IS_FALSE=false ' ,
31+ 'GET_DEPENDING_ON_DEFAULT=default ' ,
32+ ]));
33+
34+ \Dotenv \Dotenv::createImmutable (base_path ())->load ();
35+
2336 env ('FILLED ' );
2437 env ('NOT_FILLED ' );
2538 env ('FILLED_WITH_FALSE ' );
@@ -31,25 +44,25 @@ public function it_checks_if_used_env_vars_are_defined()
3144
3245 env ('UNDEFINED ' );
3346 getenv ('GET_UNDEFINED ' );
34- // Doubles should be ignored
35- env ('UNDEFINED ' );
47+ env ('UNDEFINED ' );
3648 getenv ('GET_UNDEFINED ' );
3749
3850 $ config = [
3951 'directories ' => [
40- __DIR__
52+ __DIR__ ,
4153 ],
4254 ];
4355
44- $ check = new UsedEnvironmentVariablesAreDefined ();
56+ $ check = new \ BeyondCode \ SelfDiagnosis \ Checks \ UsedEnvironmentVariablesAreDefined ();
4557
4658 $ this ->assertFalse ($ check ->check ($ config ));
47- $ this ->assertSame ($ check ->amount , 2 );
59+ $ this ->assertSame (2 , $ check ->amount );
4860 $ this ->assertContains ('UNDEFINED ' , $ check ->undefined );
4961 $ this ->assertContains ('GET_UNDEFINED ' , $ check ->undefined );
50- $ this ->assertSame (
51- "2 used environmental variables are undefined: \nUNDEFINED \nGET_UNDEFINED " ,
52- $ check ->message ($ config )
53- );
62+ $ this ->assertStringContainsString ('2 used environmental variables are undefined: ' , $ check ->message ($ config ));
63+ $ this ->assertStringContainsString ('UNDEFINED ' , $ check ->message ($ config ));
64+ $ this ->assertStringContainsString ('GET_UNDEFINED ' , $ check ->message ($ config ));
65+
66+ unlink ($ envPath );
5467 }
5568}
0 commit comments