-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
586301a
commit 3d1062b
Showing
11 changed files
with
109 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Atoolo\Search\Console\Command; | ||
|
||
use Atoolo\Resource\Loader\ServerVarResourceBaseLocator; | ||
use Atoolo\Resource\ResourceBaseLocator; | ||
|
||
class ResourceBaseLocatorBuilder | ||
{ | ||
public function build(string $resourceDir): ResourceBaseLocator | ||
{ | ||
$subDirectory = null; | ||
if (is_dir($resourceDir . '/objects')) { | ||
$subDirectory = 'objects'; | ||
} | ||
$_SERVER['RESOURCE_ROOT'] = $resourceDir; | ||
return new ServerVarResourceBaseLocator( | ||
'RESOURCE_ROOT', | ||
$subDirectory | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Atoolo\Search\Test\Console\Command; | ||
|
||
use Atoolo\Search\Console\Command\ResourceBaseLocatorBuilder; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(ResourceBaseLocatorBuilder::class)] | ||
class ResourceBaseLocatorBuilderTest extends TestCase | ||
{ | ||
public function testBuild(): void | ||
{ | ||
|
||
$resourceDir = __DIR__ . | ||
'/../../../var/test/ResourceBaseLocatorBuilderTest'; | ||
$objectsDir = $resourceDir . '/objects'; | ||
mkdir($objectsDir, 0777, true); | ||
|
||
$builder = new ResourceBaseLocatorBuilder(); | ||
$locator = $builder->build($resourceDir); | ||
|
||
$this->assertEquals( | ||
$objectsDir, | ||
$locator->locate(), | ||
'unexpected resource dir' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters