Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
add cover units test
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Aug 31, 2020
1 parent ad8d2cd commit 2193fa7
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
115 changes: 115 additions & 0 deletions tests/GDCoverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

namespace Bavix\Glow\Test;

use Bavix\Glow\Adapters\Cover;

class GDCoverTest extends TestCase
{

/**
* @var string
*/
protected $driver = 'gd';

/**
* @dataProvider sizes
* @param string $path
* @param array $data
* @param array $units
* @return void
*/
public function testSizeResultImage(string $path, array $data, array $units): void
{
$adapter = new Cover($this->imageManager);
$image = $this->imageManager->make($path);
$processed = $adapter->apply($image, $data);

self::assertEquals($units['width'], $processed->width());
self::assertEquals($units['height'], $processed->height());
$processed->destroy();
$image->destroy();
}

/**
* @return array[]
*/
public function sizes(): array
{
return [
[
__DIR__ . '/images/width.jpg',
[
'width' => 500,
'height' => 500,
],
['width' => 500, 'height' => 500],
],
[
__DIR__ . '/images/width.jpg',
[
'width' => 800,
'height' => 800,
],
['width' => 800, 'height' => 800],
],
[
__DIR__ . '/images/width.jpg',
[
'width' => 780,
'height' => 462,
],
['width' => 780, 'height' => 462],
],
[
__DIR__ . '/images/height.jpg',
[
'width' => 500,
'height' => 500,
],
['width' => 500, 'height' => 500],
],
[
__DIR__ . '/images/height.jpg',
[
'width' => 800,
'height' => 800,
],
['width' => 800, 'height' => 800],
],
[
__DIR__ . '/images/height.jpg',
[
'width' => 780,
'height' => 462,
],
['width' => 780, 'height' => 462],
],
[
__DIR__ . '/images/square.jpg',
[
'width' => 500,
'height' => 500,
],
['width' => 500, 'height' => 500],
],
[
__DIR__ . '/images/square.jpg',
[
'width' => 800,
'height' => 800,
],
['width' => 800, 'height' => 800],
],
[
__DIR__ . '/images/square.jpg',
[
'width' => 780,
'height' => 462,
],
['width' => 780, 'height' => 462],
],
];
}

}
11 changes: 11 additions & 0 deletions tests/ImagickCoverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Bavix\Glow\Test;

class ImagickCoverTest extends GDCoverTest
{
/**
* @var string
*/
protected $driver = 'imagick';
}

0 comments on commit 2193fa7

Please sign in to comment.