Skip to content

Commit

Permalink
Merge branch '8.x' into 9.x
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Aug 26, 2024
2 parents db7ba7a + 17329ea commit 7b823dd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG-8.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

This changelog references the relevant changes (bug and security fixes) done to `orchestra/workbench`.

## 8.10.0

Released: 2024-08-26

### Changes

* Allows following methods on `Orchestra\Workbench\Workbench` to accept arrays:
- `laravelPath()`
- `packagePath()`
- `path()`

## 8.9.0

Released: 2024-08-14
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"laravel/tinker": "^2.9",
"nunomaduro/collision": "^8.0",
"orchestra/canvas": "^9.1",
"orchestra/testbench-core": "^9.2",
"orchestra/testbench-core": "^9.4",
"spatie/laravel-ray": "^1.35",
"symfony/polyfill-php83": "^1.28",
"symfony/yaml": "^7.0"
Expand Down
14 changes: 9 additions & 5 deletions src/Workbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Illuminate\Support\Arr;

use function Illuminate\Filesystem\join_paths;

/**
* @phpstan-import-type TWorkbenchConfig from \Orchestra\Testbench\Foundation\Config
*/
Expand All @@ -16,23 +14,29 @@ class Workbench
*/
public static function laravelPath(array|string $path = ''): string
{
return app()->basePath(join_paths(...Arr::wrap($path)));
return app()->basePath(
\Orchestra\Testbench\join_paths(...Arr::wrap(\func_num_args() > 1 ? \func_get_args() : $path))
);
}

/**
* Get the path to the package folder.
*/
public static function packagePath(array|string $path = ''): string
{
return \Orchestra\Testbench\package_path($path);
return \Orchestra\Testbench\package_path(
...Arr::wrap(\func_num_args() > 1 ? \func_get_args() : $path)
);
}

/**
* Get the path to the workbench folder.
*/
public static function path(array|string $path = ''): string
{
return \Orchestra\Testbench\workbench_path($path);
return \Orchestra\Testbench\workbench_path(
...Arr::wrap(\func_num_args() > 1 ? \func_get_args() : $path)
);
}

/**
Expand Down
20 changes: 17 additions & 3 deletions tests/WorkbenchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Orchestra\Workbench\Workbench;
use PHPUnit\Framework\Attributes\Test;

use function Illuminate\Filesystem\join_paths;

class WorkbenchTest extends TestCase
{
use WithWorkbench;
Expand Down Expand Up @@ -42,6 +40,14 @@ public function it_can_resolve_package_path()
$this->assertSame(
realpath(__DIR__.'/../testbench.yaml'), Workbench::packagePath('testbench.yaml')
);

$this->assertSame(
realpath(__FILE__), Workbench::packagePath('tests', 'WorkbenchTest.php')
);

$this->assertSame(
realpath(__FILE__), Workbench::packagePath(['tests', 'WorkbenchTest.php'])
);
}

#[Test]
Expand All @@ -52,7 +58,15 @@ public function it_can_resolve_workbench_path()
);

$this->assertSame(
realpath(__DIR__.'/../workbench/dist/app.js'), Workbench::path(join_paths('dist', 'app.js'))
realpath(__DIR__.'/../workbench/dist/app.js'), Workbench::path('dist'.DIRECTORY_SEPARATOR.'app.js')
);

$this->assertSame(
realpath(__DIR__.'/../workbench/dist/app.js'), Workbench::path('dist', 'app.js')
);

$this->assertSame(
realpath(__DIR__.'/../workbench/dist/app.js'), Workbench::path(['dist', 'app.js'])
);
}

Expand Down

0 comments on commit 7b823dd

Please sign in to comment.