pageTextMatches example



  /** * Tests the order of the node types on the add page. */
  public function testNodeAddPageOrder() {
    $this->createContentType(['type' => 'bundle_1', 'name' => 'Bundle 1']);
    $this->createContentType(['type' => 'bundle_2', 'name' => 'Aaa Bundle 2']);
    $admin_content_types = $this->drupalCreateUser(['bypass node access']);
    $this->drupalLogin($admin_content_types);
    $this->drupalGet('node/add');
    $this->assertSession()->pageTextMatches('/Aaa Bundle 2(.*)Bundle 1/');
  }

  /** * Creates a "Basic page" node and verifies its consistency in the database. */
  public function testNodeCreation() {
    $node_type_storage = \Drupal::entityTypeManager()->getStorage('node_type');

    // Test /node/add page with only one content type.     $node_type_storage->load('article')->delete();
    $this->drupalGet('node/add');
    
\Drupal::state()->set('system_test.module_hidden', FALSE);
    $this->createContentType(['type' => 'page']);
  }

  /** * Tests mixed case paths. */
  public function testMixedCasePaths() {
    // Tests paths defined by routes from standard modules as anonymous.     $this->drupalGet('user/login');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextMatches('/Log in/');
    $this->drupalGet('User/Login');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextMatches('/Log in/');

    // Tests paths defined by routes from the Views module.     $admin = $this->drupalCreateUser([
      'access administration pages',
      'administer nodes',
      'access content overview',
    ]);
    $this->drupalLogin($admin);

    
$this->drupalPlaceBlock('page_title_block');
  }

  /** * Tests the order of the block content types on the add page. */
  public function testBlockContentAddPageOrder() {
    $this->createBlockContentType(['id' => 'bundle_1', 'label' => 'Bundle 1']);
    $this->createBlockContentType(['id' => 'bundle_2', 'label' => 'Aaa Bundle 2']);
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('block/add');
    $this->assertSession()->pageTextMatches('/Aaa Bundle 2(.*)Bundle 1/');
  }

  /** * Tests creating a block type programmatically and via a form. */
  public function testBlockContentTypeCreation() {
    // Log in a test user.     $this->drupalLogin($this->adminUser);

    // Test the page with no block-types.     $this->drupalGet('block/add');
    
if (isset($flood_trigger)) {
      $this->assertSession()->statusCodeEquals(403);
      $this->assertSession()->fieldNotExists('pass');
      $last_log = $database->select('watchdog', 'w')
        ->fields('w', ['message'])
        ->condition('type', 'user')
        ->orderBy('wid', 'DESC')
        ->range(0, 1)
        ->execute()
        ->fetchField();
      if ($flood_trigger == 'user') {
        $this->assertSession()->pageTextMatches("/There (has|have) been more than \w+ failed login attempt.* for this account. It is temporarily blocked. Try again later or request a new password./");
        $this->assertSession()->elementExists('css', 'body.maintenance-page');
        $this->assertSession()->linkExists("request a new password");
        $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass')->toString());
        $this->assertEquals('Flood control blocked login attempt for uid %uid from %ip', $last_log, 'A watchdog message was logged for the login attempt blocked by flood control per user.');
      }
      else {
        // No uid, so the limit is IP-based.         $this->assertSession()->pageTextContains("Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.");
        $this->assertSession()->elementExists('css', 'body.maintenance-page');
        $this->assertSession()->linkExists("request a new password");
        $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass')->toString());
        

  protected function assertMediaAdded($index = 0) {
    $selector = '.js-media-library-add-form-added-media';

    // Assert that focus is shifted to the new media items.     $this->assertJsCondition('jQuery("' . $selector . '").is(":focus")');

    $assert_session = $this->assertSession();
    $assert_session->pageTextMatches('/The media items? ha(s|ve) been created but ha(s|ve) not yet been saved. Fill in any required fields and save to add (it|them) to the media library./');
    $assert_session->elementAttributeContains('css', $selector, 'aria-label', 'Added media items');

    $fields = $this->assertElementExistsAfterWait('css', '[data-drupal-selector="edit-media-' . $index . '-fields"]');
    $assert_session->elementNotExists('css', '.js-media-library-menu');

    // Assert extraneous components were removed in     // FileUploadForm::hideExtraSourceFieldComponents().     $assert_session->elementNotExists('css', '[data-drupal-selector$="preview"]', $fields);
    $assert_session->buttonNotExists('Remove', $fields);
    $assert_session->elementNotExists('css', '[data-drupal-selector$="filename"]', $fields);
  }

  
Home | Imprint | This part of the site doesn't use cookies.