-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated and expanded automated tests to cover config object
- Loading branch information
1 parent
eb99bd7
commit c906eeb
Showing
7 changed files
with
156 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use CoenJacobs\Mozart\Config\Composer; | ||
use CoenJacobs\Mozart\Config\Mozart; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ConfigMapperTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
#[Test] | ||
public function it_creates_a_valid_config_object_based_on_composer_file() | ||
{ | ||
$config = Composer::loadFromFile(__DIR__ . '/config-mapper-test.json'); | ||
$this->assertInstanceOf(Composer::class, $config); | ||
$this->assertInstanceOf(Mozart::class, $config->getExtra()->getMozart()); | ||
$this->assertCount(4, $config->autoload->getAutoloaders()); | ||
} | ||
} |
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 @@ | ||
{ | ||
"require": { | ||
"pimple/pimple": "^3.5" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"Mozart\\RandomDir\\": "old_files/", | ||
"Mozart\\Multiples\\": [ "another_dir", "more_dirs" ] | ||
}, | ||
"psr-4": { | ||
"Mozart\\TestProject\\": "src/", | ||
"Mozart\\MultipleDirs\\": [ "packages/test/src/", "packages/more/src/" ] | ||
} | ||
}, | ||
"extra": { | ||
"mozart": { | ||
"dep_namespace": "Mozart\\TestProject\\Dependencies", | ||
"dep_directory": "/src/dependencies", | ||
"classmap_directory": "/classes/", | ||
"classmap_prefix": "MozartDependency_", | ||
"packages": [ | ||
"pimple/pimple" | ||
], | ||
"excluded_packages": [ | ||
], | ||
"override_autoload": { | ||
}, | ||
"delete_vendor_directories": true | ||
} | ||
} | ||
} |
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,67 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use CoenJacobs\Mozart\Console\Commands\Compose; | ||
use PHPUnit\Framework\TestCase; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ExcludedPackagesTest extends TestCase { | ||
private string $testsWorkingDir; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->testsWorkingDir = __DIR__ . '/temptestdir'; | ||
if (!file_exists($this->testsWorkingDir)) { | ||
mkdir($this->testsWorkingDir); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
#[Test] | ||
public function it_excludes_handling_specified_packages(): void | ||
{ | ||
copy(__DIR__ . '/excluded-packages.json', $this->testsWorkingDir . '/composer.json'); | ||
|
||
chdir($this->testsWorkingDir); | ||
|
||
exec('composer update'); | ||
|
||
$inputInterfaceMock = $this->createMock(InputInterface::class); | ||
$outputInterfaceMock = $this->createMock(OutputInterface::class); | ||
|
||
$mozartCompose = new Compose(); | ||
|
||
$result = $mozartCompose->run($inputInterfaceMock, $outputInterfaceMock); | ||
$this->assertEquals(0, $result); | ||
$this->assertDirectoryDoesNotExist($this->testsWorkingDir . '/vendor/pimple/pimple'); | ||
$this->assertDirectoryExists($this->testsWorkingDir . '/vendor/psr/container'); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
$dir = $this->testsWorkingDir; | ||
|
||
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); | ||
$files = new RecursiveIteratorIterator( | ||
$it, | ||
RecursiveIteratorIterator::CHILD_FIRST | ||
); | ||
foreach ($files as $file) { | ||
if ($file->isDir()) { | ||
rmdir($file->getRealPath()); | ||
} else { | ||
unlink($file->getRealPath()); | ||
} | ||
} | ||
rmdir($dir); | ||
chdir(__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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"require": { | ||
"pimple/pimple": "^3.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Mozart\\TestProject\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"mozart": { | ||
"dep_namespace": "Mozart\\TestProject\\Dependencies", | ||
"dep_directory": "/src/dependencies", | ||
"classmap_directory": "/classes/", | ||
"classmap_prefix": "MozartDependency_", | ||
"packages": [ | ||
"pimple/pimple" | ||
], | ||
"excluded_packages": [ | ||
"psr/container" | ||
], | ||
"override_autoload": {}, | ||
"delete_vendor_directories": true | ||
} | ||
} | ||
} |
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