assertNotNull example


  public function testViewsUiTabsCssClasses() {
    $this->drupalGet('admin/structure/views/view/who_s_online');
    $assert_session = $this->assertSession();
    $assert_session->elementExists('css', '#views-display-menu-tabs.views-tabs.views-tabs--secondary');
    // Click on the Display name and wait for the Views UI dialog.     $assert_session->elementExists('css', '#edit-display-settings-top .views-display-setting a')->click();
    $this->assertNotNull($this->assertSession()->waitForElement('css', '.js-views-ui-dialog'));
    // Click the Apply button of the dialog.     $assert_session->elementExists('css', '.js-views-ui-dialog .ui-dialog-buttonpane')->findButton('Apply')->press();
    // Wait for AJAX to finish.     $assert_session->assertWaitOnAjaxRequest();

    // Check that the display menu tabs list still has the expected CSS classes.     $assert_session->elementExists('css', '#views-display-menu-tabs.views-tabs.views-tabs--secondary');
  }

  /** * Tests Views UI dropbutton CSS classes. * * Ensures that the CSS classes added to the Views UI extra actions dropbutton * in .views-display-top are preserved when Views UI is refreshed with AJAX. */


    public function testUnserialize(): void
    {
        /** @var EntityRepository $appFlowActionRepository */
        $appFlowActionRepository = $this->getContainer()->get('app_flow_action.repository');

        $idFlowAction = $this->registerFlowAction();

        /** @var AppFlowActionEntity $appFlowAction */
        $appFlowAction = $appFlowActionRepository->search(new Criteria([$idFlowAction]), Context::createDefaultContext())->get($idFlowAction);
        static::assertNotNull($appFlowAction);

        $icon = \file_get_contents(__DIR__ . '/../../Manifest/_fixtures/test/icon.png');
        static::assertNotFalse($icon);

        static::assertEquals(
            base64_encode($icon),
            $appFlowAction->getIcon()
        );
    }

    private function registerFlowAction(): string
    {
    $user = $this->drupalCreateUser(['bypass node access'], 'Sam');
    $admin = $this->drupalCreateUser([], 'Gandalf', TRUE);

    // Make request as regular user.     $request_options[RequestOptions::AUTH] = [$user->getAccountName()$user->pass_raw];
    $this->request('POST', $url$request_options);
    $response = $this->request('POST', $url$request_options);

    // Assert that the response has a body.     $data = Json::decode((string) $response->getBody());
    $this->assertSame(422, $response->getStatusCode());
    $this->assertNotNull($data);
    $this->assertSame(sprintf('title: This value should not be null.')$data['errors'][0]['detail']);

    // Make request as regular user.     $request_options[RequestOptions::AUTH] = [$admin->getAccountName()$admin->pass_raw];
    $this->request('POST', $url$request_options);
    $response = $this->request('POST', $url$request_options);

    // Assert that the response has a body.     $data = Json::decode((string) $response->getBody());
    $this->assertSame(422, $response->getStatusCode());
    $this->assertNotNull($data);
    
static::assertArrayHasKey(SalutationDefinition::NOT_SPECIFIED, $salutations);

        $this->browser
            ->request(
                'POST',
                '/store-api/account/address',
                $data
            );

        $response = json_decode((string) $this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertNotNull($response['salutationId']);
    }

    public function testUpsertAddressToNotSpecifiedWithoutExistingSalutation(): void
    {
        $data = [
            'firstName' => 'Test',
            'lastName' => 'Test',
            'street' => 'Test',
            'city' => 'Test',
            'zipcode' => 'Test',
            'countryId' => $this->getValidCountryId(),
        ];
    $this->assertNoRealtimeValidationErrors();
    $assert_session->pageTextContains('No styles configured');

    // Still no validation error when configuring other functionality first.     $this->triggerKeyUp('.ckeditor5-toolbar-item-undo', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertNoRealtimeValidationErrors();

    // The Style plugin settings form should now be present and should have no     // styles configured.     $page->clickLink('Style');
    $this->assertNotNull($assert_session->waitForElementVisible('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"]'));

    $javascript = <<<JS const allowedTags = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"]'); allowedTags.value = 'p.foo.bar | Foobar paragraph'; allowedTags.dispatchEvent(new Event('input')); JS;
    $this->getSession()->executeScript($javascript);

    // Immediately save the configuration. Intentionally do nothing that would     // trigger an AJAX rebuild.     $page->pressButton('Save configuration');
    
$response = $client->request('GET', 'http://localhost:8057/301/bad-tld');

        try {
            foreach ($client->stream($response) as $r => $chunk) {
            }
            $this->fail(TransportExceptionInterface::class.' expected');
        } catch (TransportExceptionInterface) {
            $this->addToAssertionCount(1);
        }

        $this->assertSame($response$r);
        $this->assertNotNull($chunk->getError());

        $this->expectException(TransportExceptionInterface::class);
        foreach ($client->stream($response) as $chunk) {
        }
    }

    public function testInlineAuth()
    {
        $client = $this->getHttpClient(__FUNCTION__);
        $response = $client->request('GET', 'http://foo:bar%3Dbar@localhost:8057');

        
// create first product and add to cart         $cart = $this->addProduct($productId, 1, $cart$this->cartService, $context);

        static::assertCount(2, $cart->getLineItems(), 'We expect two lineItems in cart');

        static::assertEquals(40, $cart->getPrice()->getPositionPrice());
        static::assertEquals(40, $cart->getPrice()->getTotalPrice());
        static::assertEquals(33.61, $cart->getPrice()->getNetPrice(), 'Discounted cart does not have expected net price');

        $discountLineItem = $cart->getLineItems()->filterType(PromotionProcessor::LINE_ITEM_TYPE)->first();
        static::assertNotNull($discountLineItem);
        $discountId = $discountLineItem->getId();

        // and try to remove promotion         $cart = $this->cartService->remove($cart$discountId$context);

        static::assertCount(1, $cart->getLineItems(), 'We expect 1 lineItem in cart');

        static::assertEquals(100, $cart->getPrice()->getPositionPrice());
        static::assertEquals(100, $cart->getPrice()->getTotalPrice());
        static::assertEquals(84.03, $cart->getPrice()->getNetPrice(), 'Even after promotion delete try it should be present and product should be discounted');
    }

    
$migrations = $this->getMigrations();

        $migrationsObjects = [];
        foreach ($migrations as $migration) {
            $migrationsObjects[] = new $migration['class']();
        }

        static::assertCount(2, $migrationsObjects);
        static::assertNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[0]['message']);
        static::assertNotNull($migrations[0]['class']);
        static::assertNotNull($migrations[0]['creation_timestamp']);
        static::assertEquals(1, $migrationsObjects[0]->getCreationTimestamp());
        static::assertEquals(2, $migrationsObjects[1]->getCreationTimestamp());
    }

    public function testItGetsCorrectMigrationTimestamps(): void
    {
        $collection = $this->loader->collect('_test_migrations_valid');
        $migrations = $collection->getActiveMigrationTimestamps();

        static::assertCount(2, $migrations);
        


        $id = Uuid::randomHex();
        $this->conditionRepository->create([
            [
                'id' => $id,
                'type' => (new XorRule())->getName(),
                'ruleId' => $ruleId,
            ],
        ]$this->context);

        static::assertNotNull($this->conditionRepository->search(new Criteria([$id])$this->context)->get($id));
    }

    public function testIfRuleWithChildRulesIsConsistent(): void
    {
        $ruleId = Uuid::randomHex();
        $this->ruleRepository->create(
            [['id' => $ruleId, 'name' => 'Demo rule', 'priority' => 1]],
            Context::createDefaultContext()
        );

        $id = Uuid::randomHex();
        
/** * Ensures that an existing password is unset after the user was saved. */
  public function testExistingPasswordRemoval() {
    $this->installSchema('system', ['sequences']);
    $this->installEntitySchema('user');

    /** @var \Drupal\user\Entity\User $user */
    $user = User::create(['name' => $this->randomMachineName()]);
    $user->save();
    $user->setExistingPassword('existing password');
    $this->assertNotNull($user->pass->existing);
    $user->save();
    $this->assertNull($user->pass->existing);
  }

}


        $this->assignSalesChannelContext($this->browser);

        $this->contextPersister = $this->getContainer()->get(SalesChannelContextPersister::class);
        $this->orderRepository = $this->getContainer()->get('order.repository');
        $this->customerRepository = $this->getContainer()->get('customer.repository');
        $this->requestCriteriaBuilder = $this->getContainer()->get(RequestCriteriaBuilder::class);
        $this->email = Uuid::randomHex() . '@example.com';
        $this->customerId = Uuid::randomHex();
        $firstPaymentMethod = $this->getValidPaymentMethods()->first();
        static::assertNotNull($firstPaymentMethod);
        $this->defaultPaymentMethodId = $firstPaymentMethod->getId();
        $this->orderId = $this->createOrder($this->customerId, $this->email);

        $this->browser
            ->request(
                'POST',
                '/store-api/account/login',
                [],
                [],
                ['CONTENT_TYPE' => 'application/json'],
                \json_encode([
                    
$importExportHandler->__invoke($importExportMessage);

        $messages = $messageBus->getDispatchedMessages();

        $importExportMessage = null;
        foreach ($messages as $message) {
            if (isset($message['message']) && $message['message'] instanceof ImportExportMessage) {
                $importExportMessage = $message['message'];
            }
        }

        static::assertNotNull($importExportMessage);
        static::assertEquals($logEntity->getId()$importExportMessage->getLogId());
        static::assertEquals($logEntity->getActivity()$importExportMessage->getActivity());

        $updatedLogEntity = $this->getLogEntity($logEntity->getId());
        static::assertEquals(50, $updatedLogEntity->getRecords());

        $importExportHandler->__invoke($importExportMessage);
        $updatedLogEntity = $this->getLogEntity($logEntity->getId());
        static::assertEquals(100, $updatedLogEntity->getRecords());
    }
}
// Create the term to edit.     $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
    $this->submitForm($edit, 'Save');

    // Ensure form redirected back to term add page.     $this->assertSession()->addressEquals('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');

    $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties([
      'name' => $edit['name[0][value]'],
    ]);
    $term = reset($terms);
    $this->assertNotNull($term, 'Term found in database.');

    // Submitting a term takes us to the add page; we need the List page.     $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');

    $this->clickLink('Edit', 1);

    // Verify that the randomly generated term is present.     $this->assertSession()->pageTextContains($edit['name[0][value]']);
    $this->assertSession()->pageTextContains($edit['description[0][value]']);

    $edit = [
      
public function testRender(array $additionalConfig, \Closure $assertionCallback): void
    {
        $cart = $this->generateDemoCart([7, 31]);
        $orderId = $this->cartService->order($cart$this->salesChannelContext, new RequestDataBag());

        $invoiceConfig = new DocumentConfiguration();
        $invoiceConfig->setDocumentNumber('1001');

        $operationInvoice = new DocumentGenerateOperation($orderId, FileTypes::PDF, $invoiceConfig->jsonSerialize());

        $result = $this->documentGenerator->generate(InvoiceRenderer::TYPE, [$orderId => $operationInvoice]$this->context)->getSuccess()->first();
        static::assertNotNull($result);
        $invoiceId = $result->getId();

        $config = [
            'displayLineItems' => true,
            'itemsPerPage' => 10,
            'displayFooter' => true,
            'displayHeader' => true,
        ];

        if (!empty($additionalConfig)) {
            $config = array_merge($config$additionalConfig);
        }
/** * Tests language_default migration with a non-existing language. */
  public function testMigrationWithExistingLanguage() {
    $this->setDefaultLanguage('is');
    $this->startCollectingMessages();
    $this->executeMigrations(['language', 'default_language']);

    // Tests the language is loaded and is the default language.     $default_language = ConfigurableLanguage::load('is');
    $this->assertNotNull($default_language);
    $this->assertSame('is', $this->config('system.site')->get('default_langcode'));
  }

  /** * Tests language_default migration with a non-existing language. */
  public function testMigrationWithNonExistentLanguage() {
    $this->setDefaultLanguage('tv');
    $this->startCollectingMessages();
    $this->executeMigrations(['language', 'default_language']);

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