getText example

/** * Small helper function to get all ids in the output. * * @return array * A list of beatle ids. */
  protected function clickSortLoadIdsFromOutput() {
    $fields = $this->xpath("//td[contains(@class, 'views-field-id')]");
    $ids = [];
    foreach ($fields as $field) {
      $ids[] = (int) $field->getText();
    }
    return $ids;
  }

  /** * Assertion helper which checks whether a string is part of another string. * * @param string $haystack * The value to search in. * @param string $needle * The value to search for. * @param string $message * The message to display along with the assertion. * * @internal */


    // Verify that the 'My account' link exists before we check for its     // disappearance.     $this->assertSession()->elementsCount('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]', 1);

    // Verify that the 'My account' link is enabled. Do not assume the value of     // auto-increment is 1. Use XPath to obtain input element id and name using     // the consistent label text.     $this->drupalGet('admin/structure/menu/manage/account');
    $label = $this->xpath('//label[contains(.,:text)]/@for', [':text' => 'Enable My account menu link']);
    $this->assertSession()->checkboxChecked($label[0]->getText());

    // Disable the 'My account' link.     $edit['links[menu_plugin_id:user.page][enabled]'] = FALSE;
    $this->drupalGet('admin/structure/menu/manage/account');
    $this->submitForm($edit, 'Save');

    // Get the homepage.     $this->drupalGet('<front>');

    // Verify that the 'My account' link does not appear when disabled.     $this->assertSession()->elementNotExists('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]');
  }

        return InClassNode::class;
    }

    /** * @param InClassNode $node * * @return array<array-key, RuleError|string> */
    public function processNode(Node $node, Scope $scope): array
    {
        $doc = $node->getDocComment()?->getText() ?? '';

        if ($this->isInternal($doc)) {
            return [];
        }

        $class = $node->getClassReflection()->getName();

        if ($this->isTestClass($node)) {
            return [\sprintf('Test classes (%s) must be flagged @internal to not be captured by the BC checker', $node->getClassReflection()->getName())];
        }

        
 elseif ($value instanceof Reference) {
            return $this->getServiceCall((string) $value$value);
        } elseif ($value instanceof Parameter) {
            return $this->getParameterCall((string) $value);
        } elseif ($value instanceof Expression) {
            return $this->getExpressionCall((string) $value);
        } elseif ($value instanceof Definition) {
            return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']);
        } elseif ($value instanceof \UnitEnum) {
            return new TaggedValue('php/const', sprintf('%s::%s', $value::class$value->name));
        } elseif ($value instanceof AbstractArgument) {
            return new TaggedValue('abstract', $value->getText());
        } elseif (\is_object($value) || \is_resource($value)) {
            throw new RuntimeException(sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value)));
        }

        return $value;
    }

    private function getServiceCall(string $id, Reference $reference = null): string
    {
        if (null !== $reference) {
            switch ($reference->getInvalidBehavior()) {
                


  /** * Tests rendering caching of a views block with arguments. */
  public function testEmptyView() {
    $this->placeBlock('views_block:node_id_argument-block_1', ['region' => 'header']);
    $this->drupalGet('<front>');
    $this->assertEquals([]$this->cssSelect('div.region-header div.views-field-title'));

    $this->drupalGet($this->nodes[0]->toUrl());
    $result = $this->cssSelect('div.region-header div.views-field-title')[0]->getText();
    $this->assertEquals('test title 1', $result);

    $this->drupalGet($this->nodes[1]->toUrl());
    $result = $this->cssSelect('div.region-header div.views-field-title')[0]->getText();
    $this->assertEquals('test title 2', $result);

    $this->drupalGet($this->nodes[0]->toUrl());
    $result = $this->cssSelect('div.region-header div.views-field-title')[0]->getText();
    $this->assertEquals('test title 1', $result);
  }

  
 elseif ($value instanceof Reference) {
            return $this->getServiceCall((string) $value$value);
        } elseif ($value instanceof Parameter) {
            return $this->getParameterCall((string) $value);
        } elseif ($value instanceof Expression) {
            return $this->getExpressionCall((string) $value);
        } elseif ($value instanceof Definition) {
            return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']);
        } elseif ($value instanceof \UnitEnum) {
            return new TaggedValue('php/const', sprintf('%s::%s', $value::class$value->name));
        } elseif ($value instanceof AbstractArgument) {
            return new TaggedValue('abstract', $value->getText());
        } elseif (\is_object($value) || \is_resource($value)) {
            throw new RuntimeException(sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value)));
        }

        return $value;
    }

    private function getServiceCall(string $id, Reference $reference = null): string
    {
        if (null !== $reference) {
            switch ($reference->getInvalidBehavior()) {
                
protected function clickLink($label$index = 0) {
    $label = (string) $label;
    $links = $this->getSession()->getPage()->findAll('named', ['link', $label]);
    $this->assertArrayHasKey($index$links, 'The link ' . $label . ' was not found on the page.');
    $links[$index]->click();
  }

  /** * Retrieves the plain-text content from the current page. */
  protected function getTextContent() {
    return $this->getSession()->getPage()->getText();
  }

  /** * Get the current URL from the browser. * * @return string * The current URL. */
  protected function getUrl() {
    return $this->getSession()->getCurrentUrl();
  }

  

  public static function getSubscribedEvents() {
    return [
      ScriptEvents::POST_CREATE_PROJECT_CMD => 'displayPostCreateMessage',
      ScriptEvents::POST_INSTALL_CMD => 'displayPostCreateMessage',
    ];
  }

  public function displayPostCreateMessage(Event $event) {
    $message = new Message($this->composer->getPackage()$event->getName());
    if ($message = $message->getText()) {
      $this->io->write($message);
    }
  }

}
// Unit testing Drupal.timeDiff.refreshInterval(). Not using @dataProvider     // mechanism here in order to avoid reinstalling the site for each case.     foreach ($this->getRefreshIntervalTestCases() as $case) {
      $interval = json_encode($case['time_diff']);
      $this->assertJsCondition("Drupal.timeDiff.refreshInterval($interval, {$case['configured_refresh_interval']}, {$case['granularity']}) === {$case['computed_refresh_interval']}");
    }

    // Test the UI.     $time_element = $this->getSession()->getPage()->find('css', 'time');

    $time_diff = $time_element->getText();
    [$seconds_value] = explode(' ', $time_diff, 2);

    // Wait at least 1 second + 1 millisecond to make sure that the last time     // difference value has been refreshed.     $this->assertJsCondition("document.getElementsByTagName('time')[0].textContent != '$time_diff'", 1001);
    $time_diff = $time_element->getText();
    [$new_seconds_value] = explode(' ', $time_diff, 2);
    $this->assertGreaterThan($seconds_value$new_seconds_value);

    // Once again.     $this->assertJsCondition("document.getElementsByTagName('time')[0].textContent != '$time_diff'", 1001);
    
public function testMediaLibraryTranslations() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    // All translations should be shown in the administration overview,     // regardless of the interface language.     $this->drupalGet('nl/admin/content/media-grid');
    $assert_session->elementsCount('css', '.js-media-library-item', 6);
    $media_items = $page->findAll('css', '.js-media-library-item-preview + div');
    $media_names = [];
    foreach ($media_items as $media_item) {
      $media_names[] = $media_item->getText();
    }
    sort($media_names);
    // cSpell:disable-next-line     $this->assertSame(['Ardilla', 'Eekhoorn', 'Hert', 'Tejón', 'Vos', 'Zorro']$media_names);

    $this->drupalGet('es/admin/content/media-grid');
    $assert_session->elementsCount('css', '.js-media-library-item', 6);
    $media_items = $page->findAll('css', '.js-media-library-item-preview + div');
    $media_names = [];
    foreach ($media_items as $media_item) {
      $media_names[] = $media_item->getText();
    }

  protected function assertMessagesDisplayed(): void {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();
    $messages_locator = '#drupal-off-canvas .messages--error';
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertNotEmpty($assert_session->waitForElement('css', $messages_locator));
    $assert_session->elementTextContains('css', $messages_locator, 'Title field is required.');
    /** @var \Behat\Mink\Element\NodeElement[] $top_form_elements */
    $top_form_elements = $page->findAll('css', '#drupal-off-canvas form > *');
    // Ensure the messages are the first top level element of the form.     $this->assertStringContainsStringIgnoringCase('Title field is required.', $top_form_elements[0]->getText());
    $this->assertGreaterThan(4, count($top_form_elements));
  }

}


  /** * Ensures that the entity title is displayed. */
  public function testLayoutPageTitle() {
    $this->drupalPlaceBlock('page_title_block');
    $node = $this->createSectionNode([]);

    $this->drupalGet($node->toUrl('canonical')->toString() . '/layout');
    $this->assertSession()->titleEquals('Edit layout for The node title | Drupal');
    $this->assertEquals('Edit layout for The node title', $this->cssSelect('h1.page-title')[0]->getText());
  }

  /** * Tests that no Layout link shows without a section field. */
  public function testLayoutUrlNoSectionField() {
    $node = $this->createNode([
      'type' => 'bundle_without_section_field',
      'title' => 'The node title',
      'body' => [
        [
          
'access administration pages',
    ]));

    // From the manage display page, go to manage the layout.     $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
    $this->submitForm(['layout[enabled]' => TRUE], 'Save');
    $this->submitForm(['layout[allow_custom]' => TRUE], 'Save');
    $page->clickLink('Manage layout');

    $breadcrumb_titles = [];
    foreach ($page->findAll('css', '.breadcrumb a') as $link) {
      $breadcrumb_titles[$link->getText()] = $link->getAttribute('href');
    }
    $base_path = base_path();
    $expected = [
      'Home' => $base_path,
      'Administration' => $base_path . 'admin',
      'Structure' => $base_path . 'admin/structure',
      'Content types' => $base_path . 'admin/structure/types',
      'Bundle with section field' => $base_path . 'admin/structure/types/manage/bundle_with_section_field',
      'Manage display' => $base_path . 'admin/structure/types/manage/bundle_with_section_field/display/default',
      'External link' => 'http://www.example.com',
    ];
    

  protected function assertIds(array $expected_ids = []): void {
    $result = $this->xpath('//span[@class="field-content"]');
    $ids = [];
    foreach ($result as $element) {
      $ids[] = $element->getText();
    }
    $this->assertEquals($expected_ids$ids);
  }

}


        return [];
    }

    private function hasInternalComment(ClassMethod $node): bool
    {
        if ($node->getDocComment() === null) {
            return false;
        }

        $text = $node->getDocComment()->getText();

        return \str_contains($text, '@internal');
    }

    private function isService(Scope $scope): bool
    {
        $class = $scope->getClassReflection();
        if ($class === null) {
            return false;
        }

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