Skip to content

Commit

Permalink
Test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Zlatoslav Desyatnikov committed Oct 10, 2019
1 parent 4842844 commit cc055d2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"require": {
"ext-zip": "*",
"ext-json": "*",
"illuminate/support": "~5|~6",
"guzzlehttp/guzzle": "~6"
},
Expand Down
5 changes: 5 additions & 0 deletions tests/IntegratedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
29 changes: 29 additions & 0 deletions tests/TestCustomComposerJsonName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace JeroenG\Packager\Tests;

use Illuminate\Support\Facades\Artisan;

class TestCustomComposerJsonName extends TestCase
{
public function test_new_package_is_created_with_custom_composer_json()
{
// Create custom composer.json
$composerJsonPath = self::TEST_APP.'/composer.local.json';
file_put_contents($composerJsonPath, '{}');

Artisan::call('packager:new', ['vendor' => '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');
}
}

0 comments on commit cc055d2

Please sign in to comment.