-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
15 changed files
with
216 additions
and
30 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 |
---|---|---|
|
@@ -2,6 +2,8 @@ name: analyse | |
|
||
on: | ||
push: | ||
branches: | ||
- '*.x' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
|
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ name: audits | |
|
||
on: | ||
push: | ||
branches: | ||
- '*.x' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
|
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ name: coveralls | |
|
||
on: | ||
push: | ||
branches: | ||
- '*.x' | ||
pull_request: | ||
|
||
jobs: | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ name: tests | |
|
||
on: | ||
push: | ||
branches: | ||
- '*.x' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
|
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,23 @@ | ||
<?php | ||
|
||
namespace Orchestra\Workbench\Actions; | ||
|
||
class DumpComposerAutoloads | ||
{ | ||
/** | ||
* Construct a new action. | ||
*/ | ||
public function __construct( | ||
protected string $workingPath | ||
) {} | ||
|
||
/** | ||
* Handle the action. | ||
*/ | ||
public function handle(): void | ||
{ | ||
app('workbench.composer') | ||
->setWorkingPath($this->workingPath) | ||
->dumpAutoloads(); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace Orchestra\Workbench\Actions; | ||
|
||
class ModifyComposer | ||
{ | ||
/** | ||
* Construct a new action. | ||
*/ | ||
public function __construct( | ||
protected string $workingPath | ||
) {} | ||
|
||
/** | ||
* Handle the action. | ||
* | ||
* @param callable(array):array $callback | ||
*/ | ||
public function handle(callable $callback): void | ||
{ | ||
app('workbench.composer') | ||
->setWorkingPath($this->workingPath) | ||
->modify($callback); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
<?php | ||
|
||
namespace Orchestra\Workbench\Tests\Actions; | ||
|
||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\Support\Composer; | ||
use Mockery as m; | ||
use Orchestra\Workbench\Actions\DumpComposerAutoloads; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\Test; | ||
|
||
use function Orchestra\Testbench\join_paths; | ||
|
||
#[Group('composer')] | ||
class DumpComposerAutoloadsTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_can_run_dump_autoloads() | ||
{ | ||
$filesystem = new Filesystem; | ||
$workingPath = join_paths(__DIR__, 'stubs'); | ||
|
||
$this->instance('workbench.composer', $composer = m::mock(Composer::class, ['files' => $filesystem])); | ||
|
||
$composer->shouldReceive('setWorkingPath')->once()->with($workingPath)->andReturnSelf(); | ||
$composer->shouldReceive('dumpAutoloads')->once()->andReturnNull(); | ||
|
||
$action = new DumpComposerAutoloads($workingPath); | ||
|
||
$action->handle(); | ||
} | ||
} |
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,65 @@ | ||
<?php | ||
|
||
namespace Orchestra\Workbench\Tests\Actions; | ||
|
||
use Orchestra\Workbench\Actions\ModifyComposer; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\RequiresOperatingSystem; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use RuntimeException; | ||
|
||
use function Orchestra\Testbench\join_paths; | ||
|
||
#[RequiresOperatingSystem('Linux|DAR')] | ||
#[Group('composer')] | ||
class ModifyComposerTest extends TestCase | ||
{ | ||
/** {@inheritDoc} */ | ||
#[\Override] | ||
protected function setUp(): void | ||
{ | ||
$this->afterApplicationCreated(function () { | ||
copy(join_paths(__DIR__, 'stubs', 'composer.json'), join_paths(__DIR__, 'tmp', 'composer.json')); | ||
}); | ||
|
||
$this->beforeApplicationDestroyed(function () { | ||
@unlink(join_paths(__DIR__, 'tmp', 'composer.json')); | ||
}); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
#[Test] | ||
public function it_can_modify_composer_file() | ||
{ | ||
$workingPath = join_paths(__DIR__, 'tmp'); | ||
|
||
$action = new ModifyComposer($workingPath); | ||
|
||
$this->assertTrue(is_file(join_paths($workingPath, 'composer.json'))); | ||
$this->assertSame('{}'.PHP_EOL, file_get_contents(join_paths($workingPath, 'composer.json'))); | ||
|
||
$action->handle(function (array $content) { | ||
$content['$schema'] = 'https://getcomposer.org/schema.json'; | ||
|
||
return $content; | ||
}); | ||
|
||
$this->assertTrue(is_file(join_paths($workingPath, 'composer.json'))); | ||
$this->assertSame('{ | ||
"$schema": "https://getcomposer.org/schema.json" | ||
}', file_get_contents(join_paths($workingPath, 'composer.json'))); | ||
} | ||
|
||
#[Test] | ||
public function it_throws_exception_when_composer_file_does_not_exists() | ||
{ | ||
$workingPath = __DIR__; | ||
|
||
$this->expectException(RuntimeException::class); | ||
$this->expectExceptionMessage(\sprintf('Unable to locate `composer.json` file at [%s]', $workingPath)); | ||
|
||
$action = new ModifyComposer($workingPath); | ||
$action->handle(static fn (array $content) => $content); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Orchestra\Workbench\Tests\Actions; | ||
|
||
use Orchestra\Workbench\WorkbenchServiceProvider; | ||
|
||
abstract class TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
/** {@inheritDoc} */ | ||
#[\Override] | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
WorkbenchServiceProvider::class, | ||
]; | ||
} | ||
} |
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 @@ | ||
{} |
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,2 @@ | ||
* | ||
!.gitignore |