You are here

public function WebTestBaseTest::testAssertFieldByName in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php \Drupal\Tests\simpletest\Unit\WebTestBaseTest::testAssertFieldByName()

Tests the assertFieldByName() helper.

@dataProvider providerAssertFieldByName @covers ::assertFieldByName

Parameters

string $filename: Name of file containing the output to test.

string $name: Name of field to assert.

string $value: Value of the field to assert.

bool $expected: The expected result of the assert.

See also

\Drupal\simpletest\WebTestBase::assertFieldByName()

File

core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php, line 52
Contains \Drupal\Tests\simpletest\Unit\WebTestBaseTest.

Class

WebTestBaseTest
@coversDefaultClass \Drupal\simpletest\WebTestBase @group simpletest

Namespace

Drupal\Tests\simpletest\Unit

Code

public function testAssertFieldByName($filename, $name, $value, $expected) {
  $content = file_get_contents(__DIR__ . '/../../fixtures/' . $filename . '.html');
  $web_test = $this
    ->getMockBuilder('Drupal\\simpletest\\WebTestBase')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'getRawContent',
    'assertTrue',
    'pass',
  ))
    ->getMock();
  $web_test
    ->expects($this
    ->any())
    ->method('getRawContent')
    ->will($this
    ->returnValue($content));
  $web_test
    ->expects($this
    ->once())
    ->method('assertTrue')
    ->with($this
    ->identicalTo($expected), $this
    ->identicalTo('message'), $this
    ->identicalTo('Browser'));
  $test_method = new \ReflectionMethod('Drupal\\simpletest\\WebTestBase', 'assertFieldByName');
  $test_method
    ->setAccessible(TRUE);
  $test_method
    ->invokeArgs($web_test, array(
    $name,
    $value,
    'message',
  ));
}