You are here

public function ConstraintsTest::visibleProvider in Media entity Twitter 8

Provides test data for testTweetVisibleConstraint().

File

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

Class

ConstraintsTest
Tests media_entity_twitter constraints.

Namespace

Drupal\Tests\media_entity_twitter\Unit

Code

public function visibleProvider() {
  $visible_response = $this
    ->getMock('\\GuzzleHttp\\Psr7\\Response');
  $visible_response
    ->expects($this
    ->any())
    ->method('getStatusCode')
    ->will($this
    ->returnValue(200));
  $invisible_response = $this
    ->getMock('\\GuzzleHttp\\Psr7\\Response');
  $invisible_response
    ->expects($this
    ->once())
    ->method('getStatusCode')
    ->will($this
    ->returnValue(302));
  $invisible_response
    ->expects($this
    ->once())
    ->method('getHeader')
    ->with('location')
    ->will($this
    ->returnValue([
    'https://twitter.com/drupal8changes?protected_redirect=true',
  ]));
  return [
    'valid URL' => [
      'https://twitter.com/drupal8changes/status/649167396230578176',
      $visible_response,
      0,
    ],
    'invalid URL' => [
      'https://twitter.com/drupal8changes/status/649637310024273920',
      $invisible_response,
      1,
    ],
  ];
}