File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 "Hackphp\\ Config\\ " : " src/"
99 },
1010 "files" : [
11- " tests /helpers.php"
11+ " src /helpers.php"
1212 ]
1313 },
1414 "autoload-dev" : {
Original file line number Diff line number Diff line change 88 */
99 function configPath ($ path = null )
1010 {
11- $ dir = __DIR__ . "/config " ;
11+ $ dir = __DIR__ . "/../ config " ;
1212
1313 if ($ path ) {
1414 $ dir .= "/ " . $ path ;
1515 }
16-
16+
1717 return $ dir ;
1818 }
1919}
Original file line number Diff line number Diff line change 33namespace Hackphp \Config \Tests ;
44
55use Hackphp \Config \Config ;
6- use Hackphp \Config \Parsers \ArrayParser ;
76use PHPUnit \Framework \TestCase ;
7+ use Hackphp \Config \Parsers \ArrayParser ;
88
99class ConfigTest extends TestCase
1010{
11+ protected string $ configPath ;
12+
13+ protected function setUp (): void
14+ {
15+ $ this ->configPath = __DIR__ . "/config " ;
16+ }
17+
1118 /** @test */
1219 public function it_can_create_instance_with_default_configs ()
1320 {
@@ -24,7 +31,7 @@ public function it_can_create_instance_with_default_configs()
2431 /** @test */
2532 public function it_loads_and_parse_all_directory_files_successfully ()
2633 {
27- $ parser = new ArrayParser (configPath () );
34+ $ parser = new ArrayParser ($ this -> configPath );
2835
2936 $ config = new Config ();
3037 $ config ->addParser ($ parser );
@@ -37,7 +44,7 @@ public function it_loads_and_parse_all_directory_files_successfully()
3744 /** @test */
3845 public function it_loads_the_default_value_if_the_key_not_found ()
3946 {
40- $ parser = new ArrayParser (configPath () );
47+ $ parser = new ArrayParser ($ this -> configPath );
4148
4249 $ config = new Config ();
4350 $ config ->addParser ($ parser );
Original file line number Diff line number Diff line change 22
33namespace Hackphp \Config \Tests \Parsers ;
44
5+ use PHPUnit \Framework \TestCase ;
56use Hackphp \Config \Contracts \Parser ;
67use Hackphp \Config \Parsers \ArrayParser ;
7- use PHPUnit \Framework \TestCase ;
88
99class ArrayParserTest extends TestCase
1010{
11+ protected string $ configPath ;
12+
13+ protected function setUp (): void
14+ {
15+ $ this ->configPath = __DIR__ . "/../config " ;
16+ }
17+
1118 /** @test */
1219 public function it_must_be_instance_of_parser_interface ()
1320 {
14- $ parser = new ArrayParser (configPath () );
21+ $ parser = new ArrayParser ($ this -> configPath );
1522
1623 $ this ->assertInstanceOf (Parser::class, $ parser );
1724 }
1825
1926 /** @test */
2027 public function it_parses_files_from_the_given_directory ()
2128 {
22- $ parser = new ArrayParser (configPath ( " server ") );
29+ $ parser = new ArrayParser ($ this -> configPath . " / server " );
2330 $ parsed = $ parser ->parse ();
2431
2532 $ expected = [
@@ -35,7 +42,7 @@ public function it_parses_files_from_the_given_directory()
3542 /** @test */
3643 public function it_can_parse_nested_files ()
3744 {
38- $ parser = new ArrayParser (configPath () );
45+ $ parser = new ArrayParser ($ this -> configPath );
3946 $ parsed = $ parser ->parse ();
4047
4148 $ expected = [
You can’t perform that action at this time.
0 commit comments