Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Nov 23, 2023
2 parents 2c1ad1d + 00ddf6f commit dcacc9f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 51 deletions.
3 changes: 2 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
backupGlobals="false"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="vendor/autoload.php"
Expand All @@ -22,6 +22,7 @@
<source>
<include>
<directory suffix=".php">src/</directory>
<file>vendor/orchestra/testbench-core/src/Workbench/Workbench.php</file>
</include>
<exclude>
<file>src/Console/BuildCommand.php</file>
Expand Down
28 changes: 4 additions & 24 deletions src/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,10 @@

namespace Orchestra\Workbench;

use RuntimeException;

/**
* @deprecated use `Illuminate\Support\Composer` instead
*/
class Composer extends \Illuminate\Support\Composer
{
/**
* Modify composer content.
*
* @param callable(array):array $callback
*/
public function modify(callable $callback): void
{
$composerFile = "{$this->workingPath}/composer.json";

if (! file_exists($composerFile)) {
throw new RuntimeException("Unable to locate `composer.json` file at [{$this->workingPath}].");
}

$composer = json_decode((string) file_get_contents($composerFile), true, 512, JSON_THROW_ON_ERROR);

$composer = \call_user_func($callback, $composer);

file_put_contents(
$composerFile,
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR)
);
}
//
}
2 changes: 1 addition & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Composer;
use Orchestra\Testbench\Foundation\Console\Actions\EnsureDirectoryExists;
use Orchestra\Testbench\Foundation\Console\Actions\GeneratesFile;
use Orchestra\Workbench\Composer;
use Orchestra\Workbench\Events\InstallEnded;
use Orchestra\Workbench\Events\InstallStarted;
use Orchestra\Workbench\Workbench;
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/CreateSqliteDbCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\Test;

#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresOperatingSystem('Linux|DAR')]
#[Group('database')]
class CreateSqliteDbCommandTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/DropSqliteDbCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\Test;

#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresOperatingSystem('Linux|DAR')]
#[Group('database')]
class DropSqliteDbCommandTest extends TestCase
{
Expand Down
18 changes: 5 additions & 13 deletions tests/Http/Controllers/WorkbenchControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace Orchestra\Workbench\Tests\Http\Controllers;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Contracts\Config as ConfigContract;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\Foundation\Config;
use Orchestra\Testbench\TestCase;
use Orchestra\Workbench\WorkbenchServiceProvider;
use PHPUnit\Framework\Attributes\Test;

/**
* @covers \Orchestra\Workbench\Http\Controllers\WorkbenchController
*/
#[WithMigration]
class WorkbenchControllerTest extends TestCase
{
use RefreshDatabase;

/**
* Define environment setup.
*
Expand All @@ -39,16 +41,6 @@ protected function defineRoutes($router)
$router->get('/workbench', ['uses' => fn () => 'hello world']);
}

/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations(['--database' => 'testing']);
}

/**
* Get package providers.
*
Expand Down
15 changes: 5 additions & 10 deletions tests/Http/Middleware/CatchDefaultRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

namespace Orchestra\Workbench\Tests\Http\Middleware;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Contracts\Config as ConfigContract;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\Foundation\Config;
use Orchestra\Testbench\TestCase;
use Orchestra\Workbench\WorkbenchServiceProvider;
use PHPUnit\Framework\Attributes\Test;

#[WithMigration]
class CatchDefaultRouteTest extends TestCase
{
use RefreshDatabase;

/**
* Define environment setup.
*
Expand Down Expand Up @@ -38,16 +43,6 @@ protected function defineRoutes($router)
}]);
}

/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations(['--database' => 'testing']);
}

/**
* Get package providers.
*
Expand Down

0 comments on commit dcacc9f

Please sign in to comment.