Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from phel-lang/fix/phel-config-not-accessible…
…-as-array PhelConfig not accessible as array
- Loading branch information
Showing
9 changed files
with
100 additions
and
3 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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phel\Config; | ||
|
||
use Phel\Phel; | ||
use RuntimeException; | ||
|
||
final class PhelConfigException extends RuntimeException | ||
{ | ||
public static function wrongType(): self | ||
{ | ||
return new self( | ||
sprintf( | ||
'The "%s" must return an array or a PhelConfig object', | ||
Phel::PHEL_CONFIG_FILE_NAME, | ||
), | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/php/Integration/Command/Domain/DirectoryFinder/ComposerVendorDirectoriesFinderTest.php
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhelTest\Integration\Command\Domain\DirectoryFinder; | ||
|
||
use Phel\Command\Domain\Finder\ComposerVendorDirectoriesFinder; | ||
use Phel\Config\PhelConfigException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class ComposerVendorDirectoriesFinderTest extends TestCase | ||
{ | ||
public function test_exception_when_wrong_type(): void | ||
{ | ||
$this->expectExceptionObject(PhelConfigException::wrongType()); | ||
|
||
$finder = new ComposerVendorDirectoriesFinder(vendorDirectory: __DIR__ . '/wrong-testing-vendor'); | ||
$finder->findPhelSourceDirectories(); | ||
} | ||
|
||
public function test_find_phel_source_directories(): void | ||
{ | ||
$finder = new ComposerVendorDirectoriesFinder(vendorDirectory: __DIR__ . '/testing-vendor'); | ||
$dirs = $finder->findPhelSourceDirectories(); | ||
|
||
self::assertCount(2, $dirs); | ||
self::assertMatchesRegularExpression('#.*/testing-vendor/root-1/root-2/custom-src-2#', $dirs[0]); | ||
self::assertMatchesRegularExpression('#.*/testing-vendor/root-1/root-3/custom-src-3#', $dirs[1]); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...egration/Command/Domain/DirectoryFinder/testing-vendor/root-1/root-2/custom-src-2/hi.phel
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 @@ | ||
(ns directory-finder\testing-vendor\root-2\hi) |
9 changes: 9 additions & 0 deletions
9
...p/Integration/Command/Domain/DirectoryFinder/testing-vendor/root-1/root-2/phel-config.php
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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Phel\Command\CommandConfig; | ||
|
||
return [ | ||
CommandConfig::SRC_DIRS => ['custom-src-2'], | ||
]; |
1 change: 1 addition & 0 deletions
1
...egration/Command/Domain/DirectoryFinder/testing-vendor/root-1/root-3/custom-src-3/hi.phel
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 @@ | ||
(ns directory-finder\testing-vendor\root-3\hi) |
8 changes: 8 additions & 0 deletions
8
...p/Integration/Command/Domain/DirectoryFinder/testing-vendor/root-1/root-3/phel-config.php
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,8 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Phel\Config\PhelConfig; | ||
|
||
return (new PhelConfig()) | ||
->setSrcDirs(['custom-src-3']); |
1 change: 1 addition & 0 deletions
1
...tion/Command/Domain/DirectoryFinder/wrong-testing-vendor/root-1/root-2/custom-src/hi.phel
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 @@ | ||
(ns directory-finder\wrong-testing-vendor\root-1\root-2\custom-src\hi) |
5 changes: 5 additions & 0 deletions
5
...gration/Command/Domain/DirectoryFinder/wrong-testing-vendor/root-1/root-2/phel-config.php
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,5 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return new stdClass(); |