CropEntityProvidersTest.php in Crop API 8
File
tests/src/Kernel/CropEntityProvidersTest.php
View source
<?php
namespace Drupal\Tests\crop\Kernel;
use Drupal\crop\EntityProviderNotFoundException;
class CropEntityProvidersTest extends CropUnitTestBase {
public static $modules = [
'crop',
'file',
'image',
'user',
'system',
];
protected function setUp() {
parent::setUp();
$this->container
->get('entity.manager')
->onEntityTypeCreate($this->container
->get('entity.manager')
->getDefinition('file'));
}
public function testCropEffect() {
$file = $this
->getTestFile();
$file
->save();
$values = [
'type' => $this->cropType
->id(),
'entity_id' => $file
->id(),
'entity_type' => 'file',
'uri' => $file
->getFileUri(),
'x' => '190',
'y' => '120',
'width' => '50',
'height' => '50',
];
$crop = $this->container
->get('entity.manager')
->getStorage('crop')
->create($values);
$crop
->save();
try {
$provider = $crop
->provider();
$this
->assertTrue(TRUE, 'File entity provider plugin was found.');
} catch (EntityProviderNotFoundException $e) {
$this
->assertTrue(FALSE, 'File entity provider plugin was found.');
}
$this
->assertEquals($provider
->uri($file), $file
->getFileUri(), 'File provider plugin returned correct URI.');
}
}