public function CropEntityProvidersTest::testCropEffect in Crop API 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/CropEntityProvidersTest.php \Drupal\Tests\crop\Kernel\CropEntityProvidersTest::testCropEffect()
Tests file provider plugin.
File
- tests/
src/ Kernel/ CropEntityProvidersTest.php, line 34
Class
- CropEntityProvidersTest
- Tests entity provider plugins.
Namespace
Drupal\Tests\crop\KernelCode
public function testCropEffect() {
$file = $this
->getTestFile();
$file
->save();
// Create crop.
$values = [
'type' => $this->cropType
->id(),
'entity_id' => $file
->id(),
'entity_type' => 'file',
'uri' => $file
->getFileUri(),
'x' => '190',
'y' => '120',
'width' => '50',
'height' => '50',
];
/** @var \Drupal\crop\CropInterface $crop */
$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.');
}