assertNull example

 $this->context);

        /** @var MediaFolderEntity $folder */
        $folder = $this->mediaFolderRepository->search(new Criteria([$parentId])$this->context)->first();

        static::assertEquals(1, $folder->getChildCount());
    }

    private function assertCorrectPathWithOneSubFolderForEachParent(array $data, array $ids, int $depth): void
    {
        // expect parent path to be null         static::assertNull($this->getMediaFolderEntityFromId($data[$depth]['id'])->getPath());

        $expectedPath = '|' . $ids[$depth] . '|';

        // exclude the parent         for ($i = $depth - 1; $i >= 0; --$i) {
            $mediaFolderEntity = $this->getMediaFolderEntityFromId($data[$i]['id']);

            static::assertEquals($ids[$i]$mediaFolderEntity->getId());
            static::assertEquals($expectedPath$mediaFolderEntity->getPath());

            $expectedPath .= $mediaFolderEntity->getId() . '|';
        }
$configuration = ['rankings' => []];
    $this->assertEntity('node_search', 'node', TRUE, $configuration);
  }

  /** * Tests that search page is only migrated for modules enabled on D8 site. */
  public function testModuleExists() {
    $this->installConfig(['search']);
    $this->executeMigration('d7_search_page');

    $this->assertNull(SearchPage::load('node_search'));
    $this->assertEntity('user_search', 'user');
  }

  /** * Tests that a search page will be created if it does not exist. */
  public function testUserSearchCreate() {
    $this->enableModules(['node']);
    $this->installConfig(['search']);
    /** @var \Drupal\search\Entity\SearchPage $search_page */
    $search_page = SearchPage::load('user_search');
    
public function testCollect(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('product-name');

        $collection = $this->productNameCmsElementResolver->collect($slot$resolverContext);

        static::assertNull($collection);
    }

    public function testEnrichWithoutContext(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());
        $result = new ElementDataCollection();

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('product-name');

        
public function testRepetitiveMigrationExecution(): void
    {
        $e = null;

        try {
            $this->executeMigration();
            $this->executeMigration();
        } catch (DbalException|DbalDriverException $e) {
            static::fail($e->getMessage());
        }

        static::assertNull($e);
    }

    /** * @throws DbalDriverException * @throws DbalException */
    private function executeMigration(): void
    {
        (new Migration1670090989AddIndexOrderOrderNumber())->update($this->connection);
    }

    
/** * @dataProvider reverseTransformProvider */
    public function testReverseTransform($toTz$fromTz$to$from)
    {
        $transformer = new DateTimeToHtml5LocalDateTimeTransformer($toTz$fromTz);

        if (null !== $to) {
            $this->assertDateTimeEquals(new \DateTime($to)$transformer->reverseTransform($from));
        } else {
            $this->assertNull($transformer->reverseTransform($from));
        }
    }

    public function testReverseTransformRequiresString()
    {
        $this->expectException(TransformationFailedException::class);
        $transformer = new DateTimeToHtml5LocalDateTimeTransformer();
        $transformer->reverseTransform(12345);
    }

    public function testReverseTransformWithNonExistingDate()
    {


    public function testLogout()
    {
        $client = $this->createClient(['test_case' => 'SecurityHelper', 'root_config' => 'config.yml', 'debug' => true]);
        $client->loginUser(new InMemoryUser('chalasr', 'the-password', ['ROLE_FOO']), 'main');

        $client->request('GET', '/main/force-logout');
        $response = $client->getResponse();

        $this->assertSame(200, $response->getStatusCode());
        $this->assertNull(static::getContainer()->get('security.helper')->getUser());
        $this->assertSame(['message' => 'Logout successful']json_decode($response->getContent(), true));
    }

    public function testLogoutWithCsrf()
    {
        $client = $this->createClient(['test_case' => 'SecurityHelper', 'root_config' => 'config_logout_csrf.yml', 'debug' => true]);
        $client->loginUser(new InMemoryUser('chalasr', 'the-password', ['ROLE_FOO']), 'main');

        // put a csrf token in the storage         /** @var EventDispatcherInterface $eventDispatcher */
        $eventDispatcher = static::getContainer()->get(EventDispatcherInterface::class);
        
namespace Symfony\Component\HttpFoundation\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

class RequestStackTest extends TestCase
{
    public function testGetCurrentRequest()
    {
        $requestStack = new RequestStack();
        $this->assertNull($requestStack->getCurrentRequest());

        $request = Request::create('/foo');

        $requestStack->push($request);
        $this->assertSame($request$requestStack->getCurrentRequest());

        $this->assertSame($request$requestStack->pop());
        $this->assertNull($requestStack->getCurrentRequest());

        $this->assertNull($requestStack->pop());
    }

    
public function testCookieClearingOnLogout()
    {
        $client = $this->createClient(['test_case' => 'Logout', 'root_config' => 'config_cookie_clearing.yml']);

        $cookieJar = $client->getCookieJar();
        $cookieJar->set(new Cookie('flavor', 'chocolate', strtotime('+1 day'), null, 'somedomain'));

        $client->request('POST', '/login', ['_username' => 'johannes', '_password' => 'test']);
        $client->request('GET', '/logout');

        $this->assertRedirect($client->getResponse(), '/');
        $this->assertNull($cookieJar->get('flavor'));
    }

    public function testEnabledCsrf()
    {
        $client = $this->createClient(['test_case' => 'Logout', 'root_config' => 'config_csrf_enabled.yml']);

        $cookieJar = $client->getCookieJar();
        $cookieJar->set(new Cookie('flavor', 'chocolate', strtotime('+1 day'), null, 'somedomain'));

        $client->request('POST', '/login', ['_username' => 'johannes', '_password' => 'test']);
        $client->request('GET', '/logout');

        
$decoded = $this->serializer->decode($field$json);

        $price = $decoded->get(Defaults::CURRENCY);

        static::assertSame(5.0, $price->getNet());
        static::assertSame(5.0, $price->getGross());
        static::assertSame(10.0, $price->getListPrice()->getNet());
        static::assertSame(10.0, $price->getListPrice()->getGross());
        static::assertSame(10.0, $price->getRegulationPrice()->getNet());
        static::assertSame(10.0, $price->getRegulationPrice()->getGross());

        static::assertNull($price->getPercentage());
    }

    private function encode(array $data): string
    {
        $field = new PriceField('test', 'test');
        $existence = new EntityExistence('test', ['someId' => true], true, false, false, []);
        $keyPair = new KeyValuePair('someId', $data, false);
        $bag = new WriteParameterBag(
            $this->getContainer()->get(ProductDefinition::class),
            WriteContext::createFromContext(Context::createDefaultContext()),
            '',
            
$customerGroup = $storable->getData('customerGroup');

        static::assertEquals($customerGroup$entity);
    }

    public function testLazyLoadNullId(): void
    {
        $storable = new StorableFlow('name', Context::createDefaultContext()['customerGroupId' => null][]);
        $this->storer->restore($storable);
        $customerGroup = $storable->getData('customerGroup');

        static::assertNull($customerGroup);
    }

    public function testDispatchBeforeLoadStorableFlowDataEvent(): void
    {
        $this->dispatcher
            ->expects(static::once())
            ->method('dispatch')
            ->with(
                static::isInstanceOf(BeforeLoadStorableFlowDataEvent::class),
                'flow.storer.customer_group.criteria.event'
            );

        
$this->expectException(NoSuchPropertyException::class);
        $this->propertyAccessor->getValue($objectOrArray$path);
    }

    /** * @dataProvider getPathsWithMissingProperty */
    public function testGetValueReturnsNullIfPropertyNotFoundAndExceptionIsDisabled($objectOrArray$path)
    {
        $this->propertyAccessor = new PropertyAccessor(PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET, PropertyAccessor::DO_NOT_THROW);

        $this->assertNull($this->propertyAccessor->getValue($objectOrArray$path)$path);
    }

    /** * @dataProvider getPathsWithMissingIndex */
    public function testGetValueThrowsNoExceptionIfIndexNotFound($objectOrArray$path)
    {
        $this->assertNull($this->propertyAccessor->getValue($objectOrArray$path));
    }

    /** * @dataProvider getPathsWithMissingIndex */

        static::assertTrue($this->taxProviderRegistry->has(TestConstantTaxRateProvider::class));
        static::assertInstanceOf(TestConstantTaxRateProvider::class$this->taxProviderRegistry->get(TestConstantTaxRateProvider::class));

        static::assertTrue($this->taxProviderRegistry->has(TestGenericExceptionTaxProvider::class));
        static::assertInstanceOf(TestGenericExceptionTaxProvider::class$this->taxProviderRegistry->get(TestGenericExceptionTaxProvider::class));

        static::assertTrue($this->taxProviderRegistry->has(TestEmptyTaxProvider::class));
        static::assertInstanceOf(TestEmptyTaxProvider::class$this->taxProviderRegistry->get(TestEmptyTaxProvider::class));

        static::assertFalse($this->taxProviderRegistry->has('foo'));
        static::assertNull($this->taxProviderRegistry->get('foo'));
    }
}
$this->setRequestData('POST', []['param1' => [
            'name' => '',
            'type' => '',
            'tmp_name' => '',
            'error' => \UPLOAD_ERR_NO_FILE,
            'size' => 0,
        ]]);

        $this->requestHandler->handleRequest($form$this->request);

        $this->assertTrue($form->isSubmitted());
        $this->assertNull($form->getData());
    }

    public function testFixBuggyFilesArray()
    {
        $form = $this->createForm('param1', 'POST', true);
        $fieldForm = $this->createBuilder('field', false, ['allow_file_upload' => true])->getForm();
        $form->add($fieldForm);

        $this->setRequestData('POST', []['param1' => [
            'name' => [
                'field' => 'upload.txt',
            ],
/** * Assert that the SimpleXMLElement object has the given attributes. * * @param \SimpleXMLElement $element * The SimpleXMLElement object to check. * @param array $expected_attributes * An array of expected attributes. */
  protected function assertHasAttributes(\SimpleXMLElement $element, array $expected_attributes) {
    foreach ($expected_attributes as $attribute => $value) {
      if ($value === NULL) {
        $this->assertNull($element[$attribute]);
      }
      else {
        $this->assertSame((string) $value(string) $element[$attribute]);
      }
    }
  }

  /** * Processes text through the provided filters. * * @param string $text * The text string to be filtered. * @param string $langcode * The language code of the text to be filtered. * @param string[] $filter_ids * (optional) The filter plugin IDs to apply to the given text, in the order * they are being requested to be executed. * * @return \Drupal\filter\FilterProcessResult * The filtered text, wrapped in a FilterProcessResult object, and possibly * with associated assets, cacheability metadata and placeholders. * * @see \Drupal\filter\Element\ProcessedText::preRenderText() */
$context = Context::createDefaultContext();
        /** @var EntityRepository $repo */
        $repo = $this->getContainer()->get('seo_url_template.repository');
        $repo->create([$template]$context);

        $result = $repo->delete([['id' => $id]]$context);
        $event = $result->getEventByEntityName(SeoUrlTemplateDefinition::ENTITY_NAME);
        static::assertEquals([$id]$event->getIds());

        /** @var SeoUrlTemplateEntity|null $first */
        $first = $repo->search(new Criteria([$id])$context)->first();
        static::assertNull($first);
    }

    public static function templateUpdateDataProvider(): iterable
    {
        $templates = [
            [
                'id' => null,
                'salesChannelId' => TestDefaults::SALES_CHANNEL,
                'routeName' => ProductPageSeoUrlRoute::ROUTE_NAME,
                'entityName' => ProductDefinition::ENTITY_NAME,
                'template' => ProductPageSeoUrlRoute::DEFAULT_TEMPLATE,
            ],
Home | Imprint | This part of the site doesn't use cookies.