Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Added simple encoder test for meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
Coen Zimmerman committed Oct 2, 2018
1 parent baf0df9 commit 32dc984
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Encoder/EncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,31 @@ function it_encodes_simple_data()
static::assertEquals(['data' => 'simple'], $encoder->encode('simple'));
}

/**
* @test
*/
function it_encodes_simple_data_with_meta_data()
{
$factoryMock = $this->getMockFactory();
$repositoryMock = $this->getMockResourceRepository();
$transformerMock = $this->getMockTransformer();

$transformerMock->shouldReceive('setEncoder')->andReturnSelf();
$transformerMock->shouldReceive('setIsTop')->andReturnSelf();
$transformerMock->shouldReceive('transform')->with('simple')->andReturn(['data' => 'simple']);
$factoryMock->shouldReceive('makeFor')->with('simple')->once()->andReturn($transformerMock);

$encoder = new Encoder($factoryMock, $repositoryMock);

$encoder->setMeta(['twice' => 'tested']);
$encoder->addMeta('test', 'okay');

static::assertEquals(
['meta' => ['test' => 'okay', 'twice' => 'tested'], 'data' => 'simple'],
$encoder->encode('simple')
);
}

/**
* @test
*/
Expand Down

0 comments on commit 32dc984

Please sign in to comment.