@@ -63,6 +63,7 @@ public function test_get_sites_will_return_if_secured()
6363 $ files ->shouldReceive ('realpath ' )
6464 ->twice ()
6565 ->andReturn ($ dirPath . '/sitetwo ' , $ dirPath . '/sitethree ' );
66+ $ files ->shouldReceive ('isDir ' )->andReturn (true );
6667
6768 $ config = Mockery::mock (Configuration::class);
6869 $ config ->shouldReceive ('read ' )
@@ -117,6 +118,7 @@ public function test_get_sites_will_work_with_non_symlinked_path()
117118 ->once ()
118119 ->with ($ dirPath . '/sitetwo ' )
119120 ->andReturn ($ dirPath . '/sitetwo ' );
121+ $ files ->shouldReceive ('isDir ' )->once ()->with ($ dirPath . '/sitetwo ' )->andReturn (true );
120122
121123 $ config = Mockery::mock (Configuration::class);
122124 $ config ->shouldReceive ('read ' )
@@ -140,6 +142,41 @@ public function test_get_sites_will_work_with_non_symlinked_path()
140142 }
141143
142144
145+ public function test_get_sites_will_not_return_if_path_is_not_directory ()
146+ {
147+ $ files = Mockery::mock (Filesystem::class);
148+ $ dirPath = '/Users/usertest/parkedpath ' ;
149+ $ files ->shouldReceive ('scandir ' )
150+ ->once ()
151+ ->with ($ dirPath )
152+ ->andReturn (['sitetwo ' , 'siteone ' ]);
153+ $ files ->shouldReceive ('isLink ' )->andReturn (false );
154+ $ files ->shouldReceive ('realpath ' )->andReturn ($ dirPath . '/sitetwo ' , $ dirPath . '/siteone ' );
155+ $ files ->shouldReceive ('isDir ' )->twice ()
156+ ->andReturn (false , true );
157+
158+ $ config = Mockery::mock (Configuration::class);
159+ $ config ->shouldReceive ('read ' )
160+ ->once ()
161+ ->andReturn (['tld ' => 'local ' ]);
162+
163+ swap (Filesystem::class, $ files );
164+ swap (Configuration::class, $ config );
165+
166+ /** @var Site $site */
167+ $ site = resolve (Site::class);
168+
169+ $ sites = $ site ->getSites ($ dirPath , collect ());
170+ $ this ->assertCount (1 , $ sites );
171+ $ this ->assertSame ([
172+ 'site ' => 'siteone ' ,
173+ 'secured ' => '' ,
174+ 'url ' => 'http://siteone.local ' ,
175+ 'path ' => $ dirPath . '/siteone ' ,
176+ ], $ sites ->first ());
177+ }
178+
179+
143180 public function test_get_sites_will_work_with_symlinked_path ()
144181 {
145182 $ files = Mockery::mock (Filesystem::class);
@@ -156,6 +193,7 @@ public function test_get_sites_will_work_with_symlinked_path()
156193 ->once ()
157194 ->with ($ dirPath . '/siteone ' )
158195 ->andReturn ($ linkedPath = '/Users/usertest/linkedpath/siteone ' );
196+ $ files ->shouldReceive ('isDir ' )->andReturn (true );
159197
160198 $ config = Mockery::mock (Configuration::class);
161199 $ config ->shouldReceive ('read ' )
0 commit comments