Issue #3167034: Adding simple test coverage
parent
30baa59dec
commit
fd22a525cd
|
@ -0,0 +1,5 @@
|
||||||
|
name: 'Image lazy load'
|
||||||
|
type: module
|
||||||
|
description: 'Support module for image loading attribute tests.'
|
||||||
|
package: Testing
|
||||||
|
version: VERSION
|
|
@ -0,0 +1,6 @@
|
||||||
|
image_lazy_load_test:
|
||||||
|
path: /image-lazy-load-test
|
||||||
|
defaults:
|
||||||
|
_controller: Drupal\image_lazy_load_test\Controller\ImageLazyLoadController::renderImage
|
||||||
|
requirements:
|
||||||
|
_access: 'TRUE'
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\image_lazy_load_test\Controller;
|
||||||
|
|
||||||
|
use Drupal\Core\Controller\ControllerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ImageLazyLoadController class.
|
||||||
|
*/
|
||||||
|
class ImageLazyLoadController extends ControllerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an image using image theme.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* The render array.
|
||||||
|
*/
|
||||||
|
public function renderImage() {
|
||||||
|
return [
|
||||||
|
'#theme' => 'image',
|
||||||
|
'#uri' => '/core/themes/bartik/logo.svg',
|
||||||
|
'#alt' => 'Image lazy load testing image',
|
||||||
|
'#width' => '50%',
|
||||||
|
'#height' => '50%',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\system\Functional\Theme;
|
||||||
|
|
||||||
|
use Drupal\Tests\BrowserTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests lazy loading for images.
|
||||||
|
*
|
||||||
|
* @group Theme
|
||||||
|
*/
|
||||||
|
class ImageLoadingAttributeTest extends BrowserTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modules to enable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $modules = ['image_lazy_load_test'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $defaultTheme = 'stark';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that loading attribute is enabled for images.
|
||||||
|
*/
|
||||||
|
public function testImageLoadingAttribute() {
|
||||||
|
$this->drupalGet('image-lazy-load-test');
|
||||||
|
$this->assertSession()->responseContains('loading="lazy"');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue