assertNotEmpty example

// Create comment.     $edit = [];
    $edit['subject[0][value]'] = $this->randomMachineName(8);
    $edit['comment_body[0][value]'] = $this->randomMachineName(16);

    $this->drupalGet('comment/reply/node/' . $node->id() . '/comment');
    $this->submitForm($edit, 'Preview');
    $this->submitForm([], 'Save');
    $this->assertSession()->pageTextContains('Your comment has been posted.');
    $comments = \Drupal::entityTypeManager()->getStorage('comment')->loadByProperties(['subject' => $edit['subject[0][value]']]);
    $comment = reset($comments);
    $this->assertNotEmpty($comment->id(), 'Comment found.');

    // Create a node with two revisions, the initial one belonging to the     // cancelling user.     $revision_node = $this->drupalCreateNode(['uid' => $account->id()]);
    $revision = $revision_node->getRevisionId();
    $settings = get_object_vars($revision_node);
    $settings['revision'] = 1;
    // Set new/current revision to someone else.     $settings['uid'] = 1;
    $revision_node = $this->drupalCreateNode($settings);

    


  /** * Tests states of elements triggered by a checkbox element. */
  protected function doCheckboxTriggerTests() {
    $this->drupalGet('form-test/javascript-states-form');
    $page = $this->getSession()->getPage();

    // Find trigger and target elements.     $trigger = $page->findField('checkbox_trigger');
    $this->assertNotEmpty($trigger);
    $textfield_invisible_element = $page->findField('textfield_invisible_when_checkbox_trigger_checked');
    $this->assertNotEmpty($textfield_invisible_element);
    $textfield_required_element = $page->findField('textfield_required_when_checkbox_trigger_checked');
    $this->assertNotEmpty($textfield_required_element);
    $textfield_readonly_element = $page->findField('textfield_readonly_when_checkbox_trigger_checked');
    $this->assertNotEmpty($textfield_readonly_element);
    $textarea_readonly_element = $page->findField('textarea_readonly_when_checkbox_trigger_checked');
    $this->assertNotEmpty($textarea_readonly_element);
    $details = $this->assertSession()->elementExists('css', '#edit-details-expanded-when-checkbox-trigger-checked');
    $textfield_in_details = $details->findField('textfield_in_details');
    $this->assertNotEmpty($textfield_in_details);
    
$edit = [
      'name' => $this->randomMachineName(),
      'vid' => $vid,
    ];
    $this->drupalGet('admin/structure/taxonomy/add');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Created new vocabulary');

    // Check the created vocabulary.     $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache();
    $vocabulary = Vocabulary::load($vid);
    $this->assertNotEmpty($vocabulary, 'Vocabulary found.');

    // Delete the vocabulary.     $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id());
    $this->clickLink('Delete');
    $this->assertSession()->pageTextContains("Are you sure you want to delete the vocabulary {$vocabulary->label()}?");
    $this->assertSession()->pageTextContains('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.');

    // Confirm deletion.     $this->submitForm([], 'Delete');
    $this->assertSession()->pageTextContains("Deleted vocabulary {$vocabulary->label()}.");
    $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache();
    
'POST',
                '/store-api/account/login',
                [
                    'email' => $email,
                    'password' => 'shopware',
                ]
            );

        $response = $this->browser->getResponse();

        $contextToken = $response->headers->get(PlatformRequest::HEADER_CONTEXT_TOKEN) ?? '';
        static::assertNotEmpty($contextToken);

        $this->browser->setServerParameter('HTTP_SW_CONTEXT_TOKEN', $contextToken);
    }

    public function testDeleteNewCreatedAddress(): void
    {
        // Create         $data = [
            'salutationId' => $this->getValidSalutationId(),
            'firstName' => 'Test',
            'lastName' => 'Test',
            
// Check the path alias whitelist cache.     $whitelist = \Drupal::cache('bootstrap')->get('path_alias_whitelist');
    $this->assertTrue($whitelist->data['node']);
    $this->assertFalse($whitelist->data['admin']);

    // Visit the system path for the node and confirm a cache entry is     // created.     \Drupal::cache('data')->deleteAll();
    // Make sure the path is not converted to the alias.     $this->drupalGet(trim($edit['path[0][value]'], '/')['alias' => TRUE]);
    $this->assertNotEmpty(\Drupal::cache('data')->get('preload-paths:' . $edit['path[0][value]']), 'Cache entry was created.');

    // Visit the alias for the node and confirm a cache entry is created.     \Drupal::cache('data')->deleteAll();
    // @todo Remove this once https://www.drupal.org/node/2480077 lands.     Cache::invalidateTags(['rendered']);
    $this->drupalGet(trim($edit['alias[0][value]'], '/'));
    $this->assertNotEmpty(\Drupal::cache('data')->get('preload-paths:' . $edit['path[0][value]']), 'Cache entry was created.');
  }

  /** * Tests alias functionality through the admin interfaces. */
->add('vatIds', $constraint);

        $validator = $this->getContainer()->get(DataValidator::class);

        try {
            $validator->validate(['vatIds' => $vatIds]$validation);
        } catch (\Throwable $exception) {
            static::assertInstanceOf(ConstraintViolationException::class$exception);
            $violations = $exception->getViolations();
            $violation = $violations->get(1);

            static::assertNotEmpty($violation);
            static::assertEquals($constraint->message, $violation->getMessageTemplate());
        }
    }
}


    public function testGetValuesForChoicesEmpty()
    {
        $this->assertSame([]$this->list->getValuesForChoices([]));
    }

    public function testGetChoicesForValuesWithNull()
    {
        $values = $this->list->getValuesForChoices([null]);

        $this->assertNotEmpty($this->list->getChoicesForValues($values));
    }

    abstract protected function createChoiceList(): ChoiceListInterface;

    abstract protected function getChoices();

    abstract protected function getValues();
}
'table' => 'views_test_data',
        'field' => 'name',
        'operator' => '=',
        'value' => 'John',
        'group' => 0,
      ],
    ]);

    $this->executeView($view);

    // Make sure the query have where data.     $this->assertNotEmpty($view->query->where);

    // Check the data added.     $where = $view->query->where;
    $this->assertSame('views_test_data.name', $where[0]['conditions'][0]['field'], 'Where condition field matches');
    $this->assertSame('John', $where[0]['conditions'][0]['value'], 'Where condition value matches');
    $this->assertSame('=', $where[0]['conditions'][0]['operator'], 'Where condition operator matches');

    $this->executeView($view);

    // Check that our operator and value match on the filter.     $this->assertSame('=', $view->filter['test_filter']->operator);
    


  /** * Check using a component with an include and default context. */
  protected function checkIncludeDefaultContent(): void {
    $build = [
      '#type' => 'inline_template',
      '#template' => "{% embed('sdc_theme_test_base:my-card-no-schema') %}{% block card_body %}Foo bar{% endblock %}{% endembed %}",
    ];
    $crawler = $this->renderComponentRenderArray($build);
    $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test_base:my-card-no-schema"] .component--my-card-no-schema__body:contains("Foo bar")'));
  }

  /** * Check using a component with an include and no default context. * * This covers passing a render array to a 'string' prop, and mapping the * prop to a context variable. */
  protected function checkIncludeDataMapping(): void {
    $content = [
      'label' => [
        
$this->drupalPlaceBlock('ajax_forms_test_block');

    $this->drupalGet('');
    $session = $this->getSession();

    // Select first option and trigger ajax update.     $session->getPage()->selectFieldOption('edit-test1', 'option1');

    // DOM update: The InsertCommand in the AJAX response changes the text     // in the option element to 'Option1!!!'.     $opt1_selector = $this->assertSession()->waitForElement('css', "select[data-drupal-selector='edit-test1'] option:contains('Option 1!!!')");
    $this->assertNotEmpty($opt1_selector);
    $this->assertTrue($opt1_selector->isSelected());

    // Confirm option 3 exists.     $page = $session->getPage();
    $opt3_selector = $page->find('xpath', '//select[@data-drupal-selector="edit-test1"]//option[@value="option3"]');
    $this->assertNotEmpty($opt3_selector);

    // Confirm success message appears after a submit.     $page->findButton('edit-submit')->click();
    $this->assertSession()->waitForButton('edit-submit');
    $updated_page = $session->getPage();
    
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;

class EmptyAppTest extends TestCase
{
    public function testBootEmptyApp()
    {
        $kernel = new EmptyAppKernel('test', true);
        $kernel->boot();

        $this->assertTrue($kernel->getContainer()->hasParameter('twig.default_path'));
        $this->assertNotEmpty($kernel->getContainer()->getParameter('twig.default_path'));
    }

    protected function setUp(): void
    {
        $this->deleteTempDir();
    }

    protected function tearDown(): void
    {
        $this->deleteTempDir();
    }

    

  protected function getTranslation($config_name$key$langcode) {
    $settings_locations = $this->localeStorage->getLocations(['type' => 'configuration', 'name' => $config_name]);
    $this->assertNotEmpty($settings_locations, "$config_name should have configuration locations.");

    if (!empty($settings_locations)) {
      $source = $this->container->get('config.factory')->get($config_name)->get($key);
      $source_string = $this->localeStorage->findString(['source' => $source, 'type' => 'configuration']);
      $this->assertNotEmpty($source_string, "$config_name.$key should have a source string.");

      if (!empty($source_string)) {
        $conditions = [
          'lid' => $source_string->lid,
          'language' => $langcode,
        ];
        
'body[0][value]' => $this->randomMachineName(200),
    ];

    // Create the forum topic, preselecting the forum ID via a URL parameter.     $this->drupalGet("forum/$tid");
    $this->clickLink('Add new Forum topic');
    $this->assertSession()->addressEquals("node/add/forum?forum_id=$tid");
    $this->submitForm($edit, 'Save');

    // Check that the node exists in the database.     $node = $this->drupalGetNodeByTitle($title);
    $this->assertNotEmpty($node, 'New forum node found in database.');

    // Create a child forum.     $edit = [
      'name[0][value]' => $this->randomMachineName(20),
      'description[0][value]' => $this->randomMachineName(200),
      'parent[0]' => $tid,
    ];
    $this->drupalGet('admin/structure/forum/add/forum');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->linkExists('edit forum');

    

  protected function assertModuleConfigureRoutesExist(string $module_name, array $module_info): void {
    $route = $this->routeProvider->getRouteByName($module_info['configure']);
    $this->assertNotEmpty($routesprintf('The configure route for the "%s" module was found.', $module_name));
  }

}
'.block-field-blocknodebundle-with-section-fieldbody',
    ];
    $this->markTestSkipped("Skipped temporarily for random fails.");
    $this->assertRegionBlocksOrder(0, 'content', $expected_block_order);

    // Add a top section using the Two column layout.     $page->clickLink('Add section');
    $assert_session->waitForElementVisible('css', '#drupal-off-canvas');
    $assert_session->assertWaitOnAjaxRequest();
    $page->clickLink('Two column');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', 'input[value="Add section"]'));
    $page->pressButton('Add section');
    $this->assertRegionBlocksOrder(1, 'content', $expected_block_order);

    // Add a 'Powered by Drupal' block in the 'first' region of the new section.     $first_region_block_locator = '[data-layout-delta="0"].layout--twocol-section [data-region="first"] [data-layout-block-uuid]';
    $assert_session->elementNotExists('css', $first_region_block_locator);
    $assert_session->elementExists('css', '[data-layout-delta="0"].layout--twocol-section [data-region="first"] .layout-builder__add-block')->click();
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas a:contains("Powered by Drupal")'));
    $assert_session->assertWaitOnAjaxRequest();
    $page->clickLink('Powered by Drupal');
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', 'input[value="Add block"]'));
    
Home | Imprint | This part of the site doesn't use cookies.