From f46f12245a0bc00b80945dad86e330cb7f94a601 Mon Sep 17 00:00:00 2001 From: Zlatoslav Desyatnikov Date: Thu, 10 Oct 2019 17:46:15 +0300 Subject: [PATCH] Test added --- composer.json | 1 + tests/IntegratedTest.php | 5 +++++ tests/TestCustomComposerJsonName.php | 29 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/TestCustomComposerJsonName.php diff --git a/composer.json b/composer.json index 9d0fcba..13ce946 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ ], "require": { "ext-zip": "*", + "ext-json": "*", "illuminate/support": "~5|~6", "guzzlehttp/guzzle": "~6" }, diff --git a/tests/IntegratedTest.php b/tests/IntegratedTest.php index 45fd514..4ba67e1 100644 --- a/tests/IntegratedTest.php +++ b/tests/IntegratedTest.php @@ -11,6 +11,11 @@ public function test_new_package_is_created() Artisan::call('packager:new', ['vendor' => 'MyVendor', 'name' => 'MyPackage']); $this->seeInConsoleOutput('Package created successfully!'); + + // Check repositories entry in composer.json + $composerJsonContent = json_decode(file_get_contents(self::TEST_APP . '/composer.json'), true); + $this->assertArrayHasKey('repositories', $composerJsonContent); + $this->assertIsArray($composerJsonContent['repositories']['myvendor-mypackage']); } public function test_get_existing_package() diff --git a/tests/TestCustomComposerJsonName.php b/tests/TestCustomComposerJsonName.php new file mode 100644 index 0000000..9ecabff --- /dev/null +++ b/tests/TestCustomComposerJsonName.php @@ -0,0 +1,29 @@ + 'MyVendor', 'name' => 'MyPackage']); + + $this->seeInConsoleOutput('Package created successfully!'); + + // Check repositories entry in composer.local.json + $composerJsonContent = json_decode(file_get_contents($composerJsonPath), true); + $this->assertArrayHasKey('repositories', $composerJsonContent); + $this->assertIsArray($composerJsonContent['repositories']['myvendor-mypackage']); + } + + protected function getEnvironmentSetUp($app) + { + $app['config']->set('packager.composer_json_filename', 'composer.local.json'); + } +}