Skip to content

Commit

Permalink
Merge branch '7.x' into 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Dec 15, 2024
2 parents 59d7e96 + 0c8fb37 commit a669493
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 16 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG-7.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

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

## 7.50.0

Released: 2024-12-15

### Added

* Added `Orchestra\Testbench\transform_realpath_to_relative()` function.
* Override Laravel's `vendor:publish` command.

### Changes

* Add `$force` parameter to `Orchestra\Testbench\Workbench\Workbench::detectNamespace()` method.

## 7.49.1

Released: 2024-12-14
Expand Down
2 changes: 2 additions & 0 deletions src/Support/FluentDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use JsonSerializable;

/**
* @internal
*
* @template TKey of array-key
* @template TValue
*
Expand Down
3 changes: 3 additions & 0 deletions src/Support/PhpExecutableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use function Orchestra\Testbench\join_paths;

/**
* @internal
*/
class PhpExecutableFinder extends SymfonyPhpExecutableFinder
{
/**
Expand Down
84 changes: 68 additions & 16 deletions tests/Support/FluentDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
class FluentDecoratorTest extends TestCase
{
/** @test */
public function it_can_be_utilise_fluent_features()
public function it_can_utilise_fluent_features()
{
$fluent = new class($attributes = ['testbench' => true, 'class' => __CLASS__]) extends FluentDecorator
{
// ...
};
[$fluent, $attributes] = $this->newFluent();

$this->assertTrue(isset($fluent['testbench']));
$this->assertTrue(isset($fluent['class']));
Expand All @@ -27,30 +24,85 @@ public function it_can_be_utilise_fluent_features()
$this->assertSame($attributes, $fluent->toArray());
$this->assertSame(json_encode($attributes), $fluent->toJson());
$this->assertSame($attributes, $fluent->jsonSerialize());
}

/** @test */
public function it_can_utilise_fluent_as_object()
{
[$fluent] = $this->newFluent();

$this->assertFalse(isset($fluent->laravel));
$this->assertFalse(isset($fluent->file));
$this->assertNull($fluent->laravel);
$this->assertNull($fluent->file);

$fluent->laravel = Application::VERSION;
$fluent->file = __FILE__;

$this->assertTrue(isset($fluent->laravel));
$this->assertTrue(isset($fluent->file));
$this->assertSame(Application::VERSION, $fluent->laravel);
$this->assertSame(__FILE__, $fluent->file);

unset($fluent->file);

$this->assertTrue(isset($fluent->laravel));
$this->assertFalse(isset($fluent->file));
}

/** @test */
public function it_can_utilise_fluent_as_array()
{
[$fluent] = $this->newFluent();

$this->assertFalse(isset($fluent['laravel']));
$this->assertFalse(isset($fluent['file']));
$this->assertNull($fluent['laravel']);
$this->assertNull($fluent['file']);

$this->assertInstanceOf(FluentDecorator::class, $fluent->laravel(Application::VERSION));
$fluent['laravel'] = Application::VERSION;
$fluent['file'] = __FILE__;

$this->assertTrue(isset($fluent['laravel']));
$this->assertTrue(isset($fluent['file']));
$this->assertSame(Application::VERSION, $fluent['laravel']);
$this->assertSame(__FILE__, $fluent['file']);

unset($fluent['class']);
unset($fluent['file']);

$this->assertFalse(isset($fluent['class']));
$this->assertFalse(isset($fluent->class));
$this->assertNull($fluent['class']);
$this->assertNull($fluent->class);
$this->assertTrue(isset($fluent['laravel']));
$this->assertFalse(isset($fluent['file']));
}

$this->assertFalse(isset($fluent->file));
/** @test */
public function it_can_set_fluent_attribute_using_method_call()
{
[$fluent] = $this->newFluent();

$fluent->file = __FILE__;
$this->assertFalse(isset($fluent['laravel']));
$this->assertNull($fluent['laravel']);

$this->assertTrue(isset($fluent->file));
$this->assertInstanceOf(FluentDecorator::class, $fluent->laravel(Application::VERSION));

unset($fluent->file);
$this->assertTrue(isset($fluent['laravel']));
$this->assertSame(Application::VERSION, $fluent['laravel']);
}

$this->assertFalse(isset($fluent->file));
/**
* Create new test stubs.
*
* @return array{0: \Orchestra\Testbench\Support\FluentDecorator, 1: array<array-key, mixed>}
*/
protected function newFluent(): array
{
$attributes = ['testbench' => true, 'class' => __CLASS__];

return [
new class($attributes) extends FluentDecorator
{
// ...
},
$attributes,
];
}
}

0 comments on commit a669493

Please sign in to comment.