public function FocalPointCollectorTest::testDependenciesCollection in Acquia Content Hub 8.2
Tests dependencies calculation for an entity reference field.
Throws
\Drupal\Core\Entity\EntityStorageException
\Exception
File
- tests/
src/ Kernel/ DependencyCollector/ FocalPointCollectorTest.php, line 107
Class
- FocalPointCollectorTest
- Test focal point dependency collector.
Namespace
Drupal\Tests\acquia_contenthub\Kernel\DependencyCollectorCode
public function testDependenciesCollection() {
// Create test image file.
$file = File::create([
'uri' => 'public://test.jpg',
'uuid' => '4dcb20e3-b3cd-4b09-b157-fb3609b3fc93',
]);
$file
->save();
/** @var \Drupal\crop\CropInterface $crop */
$crop = $this->cropStorage
->create([
'type' => 'focal_point',
'entity_id' => $file
->id(),
'entity_type' => $file
->getEntityTypeId(),
'uri' => $file
->getFileUri(),
'x' => '100',
'y' => '150',
'width' => '200',
'height' => '250',
]);
$crop
->save();
// Create node.
$entity = $this
->createNode([
'type' => self::BUNDLE,
self::FIELD_NAME => $file
->id(),
]);
$dependencies = $this
->calculateDependencies($entity);
$this
->assertArrayHasKey($crop
->uuid(), $dependencies);
}