You are here

public function WebTestBaseTest::testAssertFieldByName in SimpleTest 8.3

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

tests/src/Unit/WebTestBaseTest.php, line 49

Class

WebTestBaseTest
@requires extension curl @coversDefaultClass \Drupal\simpletest\WebTestBase @group simpletest @group WebTestBase

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([
    '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, [
    $name,
    $value,
    'message',
  ]);
}