$cmsBlocks =
$cmsBlockRepository->
search($criteria,
$this->context
)->
getEntities();
static::
assertCount(2,
$cmsBlocks);
/** @var AppCmsBlockEntity $firstCmsBlock */
$firstCmsBlock =
$cmsBlocks->
filterByProperty('name', 'my-first-block'
)->
first();
static::
assertEquals('my-first-block',
$firstCmsBlock->
getName());
static::
assertEquals('First block from app',
$firstCmsBlock->
getLabel());
$firstBlockJson =
json_encode($firstCmsBlock->
getBlock(), \JSON_THROW_ON_ERROR
);
static::
assertIsString($firstBlockJson);
static::
assertJsonStringEqualsJsonFile(__DIR__ . '/_fixtures/cms/expectedFirstCmsBlock.json',
$firstBlockJson);
static::
assertEquals( $this->
stripWhitespace((string) file_get_contents(__DIR__ . '/../Manifest/_fixtures/test/Resources/cms/blocks/my-first-block/preview.html'
)),
$this->
stripWhitespace($firstCmsBlock->
getTemplate()) );
static::
assertEquals( file_get_contents(__DIR__ . '/../Manifest/_fixtures/test/Resources/cms/blocks/my-first-block/styles.css'
),
$firstCmsBlock->
getStyles() );
/** @var AppCmsBlockEntity $secondCmsBlock */
$secondCmsBlock =
$cmsBlocks->
filterByProperty('name', 'my-second-block'
)->
first();
static::
assertEquals('my-second-block',
$secondCmsBlock->
getName());
static::
assertEquals('Second block from app',
$secondCmsBlock->
getLabel());