| @@ 8-25 (lines=18) @@ | ||
| 5 | use Mockery as m; |
|
| 6 | use Graze\CiffRenderer\Parser\FieldParser\DateFormatter\DateFormatterDayOfYearFixedLength; |
|
| 7 | ||
| 8 | class DateFormatterDayOfYearFixedLengthTest extends \PHPUnit_Framework_TestCase |
|
| 9 | { |
|
| 10 | public function testFormat() |
|
| 11 | { |
|
| 12 | $dayOfYear = 3; |
|
| 13 | $date = m::mock(\DateTimeImmutable::class) |
|
| 14 | ->shouldReceive('format') |
|
| 15 | ->with('z') |
|
| 16 | ->andReturn($dayOfYear) |
|
| 17 | ->getMock(); |
|
| 18 | $format = 'i am format'; |
|
| 19 | ||
| 20 | $formatter = new DateFormatterDayOfYearFixedLength(); |
|
| 21 | $actual = $formatter->format($date, $format); |
|
| 22 | ||
| 23 | $this->assertSame('004', $actual); |
|
| 24 | } |
|
| 25 | } |
|
| 26 | ||
| @@ 8-25 (lines=18) @@ | ||
| 5 | use Mockery as m; |
|
| 6 | use Graze\CiffRenderer\Parser\FieldParser\DateFormatter\DateFormatterDayOfYear; |
|
| 7 | ||
| 8 | class DateFormatterDayOfYearTest extends \PHPUnit_Framework_TestCase |
|
| 9 | { |
|
| 10 | public function testFormat() |
|
| 11 | { |
|
| 12 | $dayOfYear = 3; |
|
| 13 | $date = m::mock(\DateTimeImmutable::class) |
|
| 14 | ->shouldReceive('format') |
|
| 15 | ->with('z') |
|
| 16 | ->andReturn($dayOfYear) |
|
| 17 | ->getMock(); |
|
| 18 | $format = 'i am format'; |
|
| 19 | ||
| 20 | $formatter = new DateFormatterDayOfYear(); |
|
| 21 | $actual = $formatter->format($date, $format); |
|
| 22 | ||
| 23 | $this->assertSame('4', $actual); |
|
| 24 | } |
|
| 25 | } |
|
| 26 | ||
| @@ 9-27 (lines=19) @@ | ||
| 6 | use Urbanplum\Bmp\Bmp; |
|
| 7 | use Graze\CiffRenderer\Renderer\GraphicResolver\GraphicResolverFilePath; |
|
| 8 | ||
| 9 | class GraphicResolverFilePathTest extends \PHPUnit_Framework_TestCase |
|
| 10 | { |
|
| 11 | public function testInvoke() |
|
| 12 | { |
|
| 13 | $filePath = '/path/to/font'; |
|
| 14 | $resourceExpected = 'resource'; |
|
| 15 | $bmp = m::mock(Bmp::class) |
|
| 16 | ->shouldReceive('create') |
|
| 17 | ->with($filePath) |
|
| 18 | ->andReturn($resourceExpected) |
|
| 19 | ->once() |
|
| 20 | ->getMock(); |
|
| 21 | ||
| 22 | $graphicResolver = new GraphicResolverFilePath($bmp); |
|
| 23 | $resourceActual = $graphicResolver($filePath); |
|
| 24 | ||
| 25 | $this->assertEquals($resourceExpected, $resourceActual); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||