You are here

class SimpleReCaptchaFormManagerTest in Simple Google reCAPTCHA 8

Class SimpleReCaptchaFormManagerTest.

@group simple_recaptcha

@coversDefaultClass \Drupal\simple_recaptcha\SimpleReCaptchaFormManager

Hierarchy

Expanded class hierarchy of SimpleReCaptchaFormManagerTest

File

tests/src/Unit/SimpleReCaptchaFormManagerTest.php, line 15

Namespace

Drupal\Tests\simple_recaptcha\Unit
View source
class SimpleReCaptchaFormManagerTest extends UnitTestCase {

  /**
   * Test the formIdInList().
   *
   * @covers ::formIdInList
   *
   * @dataProvider dataFormIdProvider
   */
  public function testFormIdInList($formId, $list, bool $expected) {
    $result = SimpleReCaptchaFormManager::formIdInList($formId, $list);
    $this
      ->assertSame($result, $expected);
  }

  /**
   * Data to test form id is detected or not.
   */
  public function dataFormIdProvider() {
    return [
      [
        'user_login_form',
        [
          'user_login_form',
          'user_pass',
          'user_register_form',
        ],
        TRUE,
      ],
      [
        'user_pass',
        [
          'user_login_form',
          'user_pass',
          'user_register_form',
        ],
        TRUE,
      ],
      [
        'user_register_form',
        [
          'user_login_form',
          'user_pass',
          'user_register_form',
        ],
        TRUE,
      ],
      [
        'user_login_form',
        [
          'user_login*',
          'user_register*',
        ],
        TRUE,
      ],
      [
        'user_pass',
        [
          'user_login*',
          'user_register*',
        ],
        FALSE,
      ],
      [
        'user_register_form',
        [
          'user_login*',
          'user_register*',
        ],
        TRUE,
      ],
      [
        'user_login_form',
        [
          'user_*',
        ],
        TRUE,
      ],
      [
        'user_pass',
        [
          'user_*',
          'user_*',
        ],
        TRUE,
      ],
      [
        'user_register_form',
        [
          'user_*',
          'user_*',
        ],
        TRUE,
      ],
      [
        'user_login_form',
        [
          'user_*_form',
        ],
        TRUE,
      ],
      [
        'user_pass',
        [
          'user_*_form',
        ],
        FALSE,
      ],
      [
        'user_register_form',
        [
          'user_*_form',
        ],
        TRUE,
      ],
      [
        'user_login_form',
        [
          '*user*',
        ],
        TRUE,
      ],
      [
        'user_pass',
        [
          '*user*',
        ],
        TRUE,
      ],
      [
        'user_register_form',
        [
          '*user*',
        ],
        TRUE,
      ],
      [
        'user_login_form',
        [
          '*_user*',
        ],
        FALSE,
      ],
      [
        'user_pass',
        [
          '*_user*',
        ],
        FALSE,
      ],
      [
        'user_register_form',
        [
          '*_user*',
        ],
        FALSE,
      ],
      [
        'user_login_form',
        [
          'user_other*',
          'user_else*',
        ],
        FALSE,
      ],
      [
        'user_pass',
        [
          'user_other*',
          'user_else*',
        ],
        FALSE,
      ],
      [
        'user_register_form',
        [
          'user_other*',
          'user_else*',
        ],
        FALSE,
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
SimpleReCaptchaFormManagerTest::dataFormIdProvider public function Data to test form id is detected or not.
SimpleReCaptchaFormManagerTest::testFormIdInList public function Test the formIdInList().
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 340