Skip to content

Commit

Permalink
Framework assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHash committed Jun 10, 2020
1 parent 7405087 commit 0145924
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/CallbackMetadataEnricher.php
Expand Up @@ -21,6 +21,6 @@ public function __construct(Closure $callable)

public function enrich(MetadataInterface $metadata): MetadataInterface
{
return call_user_func($this->callable, $metadata);
return ($this->callable)($metadata);
}
}
2 changes: 1 addition & 1 deletion src/MetadataEnricherList.php
Expand Up @@ -17,7 +17,7 @@ public function __construct(iterable $enrichers = [])
$this->init($enrichers, [MetadataEnricherInterface::class]);
}

public function prependEnricher(string $key, string $value): self
public function enrichWith(string $key, string $value): self
{
return $this->unshift(
new CallbackMetadataEnricher(
Expand Down
Expand Up @@ -16,9 +16,10 @@ final class CallbackMetadataEnricherTest extends TestCase
{
public function testEnrich(): void
{
$metadata = (new CallbackMetadataEnricher(function (Metadata $metadata) {
return $metadata->with('message', 'hello world');
}))->enrich(Metadata::makeEmpty());
$metadata = (new CallbackMetadataEnricher(
fn(Metadata $metadata): Metadata => $metadata->with('message', 'hello world')
))->enrich(Metadata::makeEmpty());

$this->assertEquals($metadata->get('message'), 'hello world');
}
}
Expand Up @@ -40,7 +40,7 @@ public function testPrependEnricher(): void
$mockEnricher = $this->createMock(MetadataEnricherInterface::class);
$mockEnricher->expects($this->once())->method('enrich')->willReturnArgument(0);
$enricherList = new MetadataEnricherList([$mockEnricher]);
$newList = $enricherList->prependEnricher('key', 'value');
$newList = $enricherList->enrichWith('key', 'value');
$this->assertCount(2, $newList);
$this->assertNotSame($enricherList, $newList);
$this->assertFalse($enricherList === $newList);
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/MetadataTest.php → tests/MetadataTest.php
Expand Up @@ -8,7 +8,7 @@

namespace Daikon\Tests\Metadata;

use Assert\InvalidArgumentException;
use Daikon\Interop\InvalidArgumentException;
use Daikon\Metadata\Metadata;
use PHPUnit\Framework\TestCase;

Expand Down

0 comments on commit 0145924

Please sign in to comment.