You are here

public function ConstraintsTest::testBadUrlsOnVisibleConstraint in Media entity Twitter 8

Tests whether the TweetVisible constraint is robust against bad URLs.

@covers \Drupal\media_entity_twitter\Plugin\Validation\Constraint\TweetVisibleConstraintValidator @covers \Drupal\media_entity_twitter\Plugin\Validation\Constraint\TweetVisibleConstraint

@dataProvider badUrlsProvider

File

tests/src/Unit/ConstraintsTest.php, line 166

Class

ConstraintsTest
Tests media_entity_twitter constraints.

Namespace

Drupal\Tests\media_entity_twitter\Unit

Code

public function testBadUrlsOnVisibleConstraint($embed_code) {
  $http_client = $this
    ->getMock('\\GuzzleHttp\\Client');
  $http_client
    ->expects($this
    ->never())
    ->method('get');
  $execution_context = $this
    ->getMockBuilder('\\Drupal\\Core\\TypedData\\Validation\\ExecutionContext')
    ->disableOriginalConstructor()
    ->getMock();
  $validator = new TweetVisibleConstraintValidator($http_client);
  $validator
    ->initialize($execution_context);
  $constraint = new TweetVisibleConstraint();
  $validator
    ->validate($this
    ->getMockFieldItem($embed_code), $constraint);
}