public function TestBaseTest::testRandomString in Drupal 8
@covers ::randomString @dataProvider providerRandomItems
File
- core/
modules/ simpletest/ tests/ src/ Unit/ TestBaseTest.php, line 111
Class
- TestBaseTest
- @requires extension curl @coversDefaultClass \Drupal\simpletest\TestBase @group simpletest @group TestBase
Namespace
Drupal\Tests\simpletest\UnitCode
public function testRandomString($length) {
$mock_test_base = $this
->getMockForAbstractClass('Drupal\\simpletest\\TestBase');
$string = $mock_test_base
->randomString($length);
$this
->assertEquals($length, strlen($string));
// randomString() should always include an ampersand ('&') and a
// greater than ('>') if $length is greater than 3.
if ($length > 4) {
$this
->assertContains('&', $string);
$this
->assertContains('>', $string);
}
}