You are here

class VideoBgModifierTest in Modifiers Pack 8

@coversDefaultClass \Drupal\modifiers_bg_video\Plugin\modifiers\VideoBgModifier @group modifiers_pack

Hierarchy

Expanded class hierarchy of VideoBgModifierTest

File

modules/modifiers_bg_video/tests/src/Unit/VideoBgModifierTest.php, line 12

Namespace

Drupal\Tests\modifiers_bg_video\Unit
View 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

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 340
VideoBgModifierTest::testModification public function @covers ::modification