assertContainsEquals example

$messages = $this->messenger->deleteByType(MessengerInterface::TYPE_STATUS);
    // Remove the first.     unset($messages[0]);

    // Re-add the second.     foreach ($messages as $message) {
      $this->messenger->addStatus($message);
    }

    // Check we only have the second one.     $this->assertCount(1, $this->messenger->messagesByType(MessengerInterface::TYPE_STATUS));
    $this->assertContainsEquals('Second message with <em>markup!</em> (not removed).', $this->messenger->deleteByType(MessengerInterface::TYPE_STATUS));

  }

  /** * Tests we don't add duplicates. * * @covers ::all * @covers ::addStatus * @covers ::addWarning * @covers ::addError * @covers ::deleteByType * @covers ::deleteAll */

    else {
      $this->assertCount($count_limited$referenceables[$this->bundle]);
    }

    // Test returned items.     foreach ($items as $item) {
      // SelectionInterface::getReferenceableEntities() always return escaped       // entity labels.       // @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::getReferenceableEntities()       $item = is_string($item) ? Html::escape($item) : $item;
      $this->assertContainsEquals($item$referenceables[$this->bundle]);
    }

    // Test ::countReferenceableEntities().     $count_referenceables = $this->selectionHandler->countReferenceableEntities($match$match_operator);
    $this->assertSame($count_referenceables$count_all);
  }

  /** * Provides test cases for ::testReferenceablesWithNoLabelKey() test. * * @return array[] */
$this->assertInstanceOf(ParameterBag::class$c->getRequestServer());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestCookies());
        $this->assertInstanceOf(ParameterBag::class$attributes);
        $this->assertInstanceOf(ParameterBag::class$c->getRequestRequest());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestQuery());
        $this->assertInstanceOf(ParameterBag::class$c->getResponseCookies());
        $this->assertSame('html', $c->getFormat());
        $this->assertEquals('foobar', $c->getRoute());
        $this->assertEquals(['name' => 'foo']$c->getRouteParams());
        $this->assertSame([]$c->getSessionAttributes());
        $this->assertSame('en', $c->getLocale());
        $this->assertContainsEquals(__FILE__, $attributes->get('resource'));
        $this->assertSame('stdClass', $attributes->get('object')->getType());

        $this->assertInstanceOf(ParameterBag::class$c->getResponseHeaders());
        $this->assertSame('OK', $c->getStatusText());
        $this->assertSame(200, $c->getStatusCode());
        $this->assertSame('application/json', $c->getContentType());
    }

    public function testCollectWithoutRouteParams()
    {
        $request = $this->createRequest([]);

        
$extension->expects($this->exactly(2))
            ->method('getConfiguration')
            ->willReturn(new FooConfiguration());

        $container = new ContainerBuilder(new ParameterBag());
        $container->registerExtension($extension);
        $container->prependExtensionConfig('foo', ['bar' => true]);

        $pass = new MergeExtensionConfigurationPass();
        $pass->process($container);

        $this->assertContainsEquals(new FileResource(__FILE__)$container->getResources());
    }

    public function testOverriddenEnvsAreMerged()
    {
        $container = new ContainerBuilder();
        $container->registerExtension(new FooExtension());
        $container->prependExtensionConfig('foo', ['bar' => '%env(FOO)%']);
        $container->prependExtensionConfig('foo', ['bar' => '%env(BAR)%', 'baz' => '%env(BAZ)%']);

        $pass = new MergeExtensionConfigurationPass();
        $pass->process($container);

        

        $translator = new Translator('en_GB');
        $translator->addLoader('yml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
        $translator->addResource('yml', __DIR__.'/fixtures/empty.yml', 'en_GB');
        $translator->addResource('yml', __DIR__.'/fixtures/resources.yml', 'en');

        // force catalogue loading         $this->assertEquals('bar', $translator->trans('foo', []));

        $resources = $translator->getCatalogue('en')->getResources();
        $this->assertCount(1, $resources);
        $this->assertContainsEquals(__DIR__.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'resources.yml', $resources);

        $resources = $translator->getCatalogue('en_GB')->getResources();
        $this->assertCount(2, $resources);
        $this->assertContainsEquals(__DIR__.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'empty.yml', $resources);
        $this->assertContainsEquals(__DIR__.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'resources.yml', $resources);
    }

    /** * @dataProvider getTransTests */
    public function testTrans($expected$id$translation$parameters$locale$domain)
    {
$expected = [
        'Unable to install the <em class="placeholder">unknown_module</em> module since it does not exist.',
        'Unable to install the <em class="placeholder">Book</em> module since it requires the <em class="placeholder">Node, Text, Field, Filter, User</em> modules.',
        'Unable to install the <em class="placeholder">unknown_theme</em> theme since it does not exist.',
        'Configuration <em class="placeholder">config_test.dynamic.dotted.config</em> depends on the <em class="placeholder">unknown</em> configuration that will not exist after import.',
        'Configuration <em class="placeholder">config_test.dynamic.dotted.existing</em> depends on the <em class="placeholder">config_test.dynamic.dotted.deleted</em> configuration that will not exist after import.',
        'Configuration <em class="placeholder">config_test.dynamic.dotted.module</em> depends on the <em class="placeholder">unknown</em> module that will not be installed after import.',
        'Configuration <em class="placeholder">config_test.dynamic.dotted.theme</em> depends on the <em class="placeholder">unknown</em> theme that will not be installed after import.',
        'Configuration <em class="placeholder">unknown.config</em> depends on the <em class="placeholder">unknown</em> extension that will not be installed after import.',
      ];
      foreach ($expected as $expected_message) {
        $this->assertContainsEquals($expected_message$error_log$expected_message);
      }
    }

    // Make a config entity have multiple unmet dependencies.     $config_entity_data = $sync->read('config_test.dynamic.dotted.default');
    $config_entity_data['dependencies'] = ['module' => ['unknown', 'dblog']];
    $sync->write('config_test.dynamic.dotted.module', $config_entity_data);
    $config_entity_data['dependencies'] = ['theme' => ['unknown', 'stark']];
    $sync->write('config_test.dynamic.dotted.theme', $config_entity_data);
    $config_entity_data['dependencies'] = ['config' => ['unknown', 'unknown2']];
    $sync->write('config_test.dynamic.dotted.config', $config_entity_data);
    

        IntlTestHelper::requireIntl($this, false);

        parent::setUp();
    }

    public function testLocalesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('en', 'en', 'English')$choices);
        $this->assertContainsEquals(new ChoiceView('en_GB', 'en_GB', 'English (United Kingdom)')$choices);
        $this->assertContainsEquals(new ChoiceView('zh_Hant_HK', 'zh_Hant_HK', 'Chinese (Traditional, Hong Kong SAR China)')$choices);
    }

    /** * @requires extension intl */
    public function testChoiceTranslationLocaleOption()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                

        IntlTestHelper::requireIntl($this, false);

        parent::setUp();
    }

    public function testCountriesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('en', 'en', 'English')$choices);
        $this->assertContainsEquals(new ChoiceView('fr', 'fr', 'French')$choices);
        $this->assertContainsEquals(new ChoiceView('my', 'my', 'Burmese')$choices);
    }

    /** * @requires extension intl */
    public function testChoiceTranslationLocaleOption()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                

                'newShippingMethodName' => 'any-other-shipping-method-name',
                'oldShippingMethodName' => 'original-shipping-method-name',
            ],
            [
                'newShippingMethodName' => 'any-other-shipping-method-name',
                'oldShippingMethodName' => 'default-shipping-method-name',
            ],
        ];

        foreach ($errorCollectionFiltered as $error) {
            static::assertContainsEquals($error->getParameters()$expectedParameters);
        }
    }

    public function testSwitchBlockedOriginalAndNoDefaultSwitchToAnyOther(): void
    {
        $errorCollection = $this->getErrorCollection(['original-shipping-method-name']);
        $salesChannelContext = $this->getSalesChannelContext(true);
        $newShippingMethod = $this->switcher->switch($errorCollection$salesChannelContext);

        static::assertSame('any-other-shipping-method-id', $newShippingMethod->getId());

        

        IntlTestHelper::requireIntl($this, false);

        parent::setUp();
    }

    public function testCurrenciesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'Euro')$choices);
        $this->assertContainsEquals(new ChoiceView('USD', 'USD', 'US Dollar')$choices);
        $this->assertContainsEquals(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar')$choices);
    }

    /** * @requires extension intl */
    public function testChoiceTranslationLocaleOption()
    {
        $choices = $this->factory
            ->create(static::TESTED_TYPE, null, [
                
use Symfony\Component\Intl\Util\IntlTestHelper;

class TimezoneTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TimezoneType';

    public function testTimezonesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Africa / Kinshasa')$choices);
        $this->assertContainsEquals(new ChoiceView('America/New_York', 'America/New_York', 'America / New York')$choices);
    }

    public function testSubmitNull($expected = null, $norm = null, $view = null)
    {
        parent::testSubmitNull($expected$norm, '');
    }

    public function testSubmitNullUsesDefaultEmptyData($emptyData = 'Africa/Kinshasa', $expectedData = 'Africa/Kinshasa')
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            
$groups = $this->grouper->group($css_assets);

    $this->assertCount(5, $groups, "5 groups created.");

    // Check group 1.     $group = $groups[0];
    $this->assertSame(-100, $group['group']);
    $this->assertSame('file', $group['type']);
    $this->assertSame('all', $group['media']);
    $this->assertTrue($group['preprocess']);
    $this->assertCount(3, $group['items']);
    $this->assertContainsEquals($css_assets['system.base.css']$group['items']);
    $this->assertContainsEquals($css_assets['js.module.css']$group['items']);

    // Check group 2.     $group = $groups[1];
    $this->assertSame(0, $group['group']);
    $this->assertSame('file', $group['type']);
    $this->assertSame('all', $group['media']);
    $this->assertTrue($group['preprocess']);
    $this->assertCount(1, $group['items']);
    $this->assertContainsEquals($css_assets['field.css']$group['items']);

    
IntlTestHelper::requireIntl($this, false);

        parent::setUp();
    }

    public function testCountriesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        // Don't check objects for identity         $this->assertContainsEquals(new ChoiceView('DE', 'DE', 'Germany')$choices);
        $this->assertContainsEquals(new ChoiceView('GB', 'GB', 'United Kingdom')$choices);
        $this->assertContainsEquals(new ChoiceView('US', 'US', 'United States')$choices);
        $this->assertContainsEquals(new ChoiceView('FR', 'FR', 'France')$choices);
        $this->assertContainsEquals(new ChoiceView('MY', 'MY', 'Malaysia')$choices);
    }

    /** * @requires extension intl */
    public function testChoiceTranslationLocaleOption()
    {
        

                'newPaymentMethodName' => 'any-other-payment-method-name',
                'oldPaymentMethodName' => 'original-payment-method-name',
            ],
            [
                'newPaymentMethodName' => 'any-other-payment-method-name',
                'oldPaymentMethodName' => 'default-payment-method-name',
            ],
        ];

        foreach ($errorCollectionFiltered as $error) {
            static::assertContainsEquals($error->getParameters()$expectedParameters);
        }
    }

    public function testSwitchBlockedOriginalAndNoDefaultSwitchToAnyOther(): void
    {
        $errorCollection = $this->getErrorCollection(['original-payment-method-name']);
        $salesChannelContext = $this->getSalesChannelContext(true);
        $newPaymentMethod = $this->switcher->switch($errorCollection$salesChannelContext);

        static::assertSame('any-other-payment-method-id', $newPaymentMethod->getId());

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