class RenameAdminPathsValidatorTest in Rename Admin Paths 8.2
@group tests
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\rename_admin_paths\Unit\Form\RenameAdminPathsValidatorTest
Expanded class hierarchy of RenameAdminPathsValidatorTest
File
- tests/
src/ Unit/ Form/ RenameAdminPathsValidatorTest.php, line 11
Namespace
Drupal\Tests\rename_admin_paths\Unit\FormView source
class RenameAdminPathsValidatorTest extends UnitTestCase {
/**
* @dataProvider defaultPaths
*
* @param string $value
*/
public function testMatchDefaultPath(string $value) {
$this
->assertTrue(RenameAdminPathsValidator::isDefaultPath($value));
}
/**
* @return \Generator
*/
public function defaultPaths() {
(yield [
'user',
]);
(yield [
'admin',
]);
(yield [
'ADMIN',
]);
(yield [
'Admin',
]);
(yield [
'USER',
]);
(yield [
'User',
]);
}
/**
* @dataProvider nonDefaultPaths
*
* @param string $value
*/
public function testDefaultPath(string $value) {
$this
->assertFalse(RenameAdminPathsValidator::isDefaultPath($value));
}
/**
* @return \Generator
*/
public function nonDefaultPaths() {
(yield [
'user2',
]);
(yield [
'myadmin',
]);
(yield [
'backend',
]);
}
/**
* @dataProvider validPaths
*
* @param string $value
*/
public function testValidPath(string $value) {
$this
->assertTrue(RenameAdminPathsValidator::isValidPath($value));
}
/**
* @return \Generator
*/
public function validPaths() {
(yield [
'backend',
]);
(yield [
'back-end',
]);
(yield [
'Backend',
]);
(yield [
'Back-End',
]);
(yield [
'Back_End',
]);
(yield [
'Back-End_123',
]);
(yield [
'admin2',
]);
(yield [
'user2',
]);
(yield [
'admin',
]);
(yield [
'user',
]);
(yield [
'Admin',
]);
}
/**
* @dataProvider invalidPaths
*
* @param string $value
*/
public function testInvalidPath(string $value) {
$this
->assertFalse(RenameAdminPathsValidator::isValidPath($value));
}
/**
* @return \Generator
*/
public function invalidPaths() {
(yield [
'backend!',
]);
(yield [
'back@end',
]);
(yield [
'(Backend)',
]);
(yield [
'Back~End',
]);
(yield [
'Back=End',
]);
(yield [
'Back-End+123',
]);
(yield [
'admin!',
]);
(yield [
'@user',
]);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RenameAdminPathsValidatorTest:: |
public | function | ||
RenameAdminPathsValidatorTest:: |
public | function | ||
RenameAdminPathsValidatorTest:: |
public | function | ||
RenameAdminPathsValidatorTest:: |
public | function | @dataProvider nonDefaultPaths | |
RenameAdminPathsValidatorTest:: |
public | function | @dataProvider invalidPaths | |
RenameAdminPathsValidatorTest:: |
public | function | @dataProvider defaultPaths | |
RenameAdminPathsValidatorTest:: |
public | function | @dataProvider validPaths | |
RenameAdminPathsValidatorTest:: |
public | function | ||
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |