class VideoBgModifierTest in Modifiers Pack 8
@coversDefaultClass \Drupal\modifiers_bg_video\Plugin\modifiers\VideoBgModifier @group modifiers_pack
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\modifiers_bg_video\Unit\VideoBgModifierTest
Expanded class hierarchy of VideoBgModifierTest
File
- modules/
modifiers_bg_video/ tests/ src/ Unit/ VideoBgModifierTest.php, line 12
Namespace
Drupal\Tests\modifiers_bg_video\UnitView source
class VideoBgModifierTest extends UnitTestCase {
/**
* @covers ::modification
*/
public function testModification() {
// Well-formed video URL.
$actual_1 = VideoBgModifier::modification('.selector', [
'video' => 'https://www.youtube.com/watch?v=video-code',
]);
$expected_css_1 = [
'all' => [
'.selector' => [
'position:relative',
],
'.selector .videojs-background-wrap' => [
'position:absolute;overflow:hidden;width:100%;height:100%;top:0;left:0;z-index:-998',
],
],
];
$expected_libraries_1 = [
'modifiers_bg_video/apply',
'modifiers_bg_video/videojs_youtube',
];
$expected_settings_1 = [
'namespace' => 'VideoBgModifier',
'callback' => 'apply',
'selector' => '.selector',
'media' => 'all',
'args' => [
'provider' => 'youtube',
'video' => 'video-code',
],
];
$expected_attributes_1 = [
'all' => [
'.selector' => [
'class' => [
'modifiers-has-background',
],
],
],
];
$this
->assertEquals($expected_css_1, $actual_1
->getCss());
$this
->assertEquals($expected_libraries_1, $actual_1
->getLibraries());
$this
->assertEquals($expected_settings_1, $actual_1
->getSettings());
$this
->assertEquals($expected_attributes_1, $actual_1
->getAttributes());
$this
->assertEmpty($actual_1
->getLinks());
// Mall-formed video URL.
$actual_2 = VideoBgModifier::modification('.selector', [
'video' => 'https://www.other-service.com/watch?v=video-code',
]);
$this
->assertEmpty($actual_2);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 | |
VideoBgModifierTest:: |
public | function | @covers ::modification |