Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
irvis committed Nov 8, 2016
1 parent 7aa2ba4 commit 74a34ec
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/iMega/Formatter/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function instanceDataProvider()
],
'expected' => new FormatterException('Wrong type'),
],
[
'data' => [
['name', 'defaultValue', '\\Exception', 0],
],
'expected' => new FormatterException('Wrong instance'),
],
];
}

Expand All @@ -69,8 +75,12 @@ public function instanceDataProvider()
public function testGetData(array $data, $name, $value, $expected)
{
$formatter = new Formatter($data);
$actual = $formatter->getData($name, $value);
$this->assertSame($expected, $actual);
try {
$actual = $formatter->getData($name, $value);
$this->assertSame($expected, $actual);
} catch (FormatterException $e) {
$this->assertEquals($expected, $e);
}
}

/**
Expand Down Expand Up @@ -114,6 +124,16 @@ public function getDataDataProvider()
'value' => 'WRONG DATE',
'expected' => '2016-11-08 10:25:00',
],
[
'data' => [
JsonType::setDefault('my_json', []),
],
'name' => 'my_json_other',
'value' => [
'foo' => 'bar',
],
'expected' => new FormatterException('Field not exists'),
],
];
}

Expand Down

0 comments on commit 74a34ec

Please sign in to comment.