assertContainsOnlyInstancesOf example

$this->connection->update('rule', ['payload' => null, 'invalid' => '1']['HEX(1)' => '1']);
        $rule = $this->repository->search(new Criteria([$id])$this->context)->get($id);
        static::assertNull($rule->get('payload'));
        $this->indexer->handle(new EntityIndexingMessage([$id]));

        $rule = $this->repository->search(new Criteria([$id])$this->context)->get($id);
        static::assertNotNull($rule->getPayload());
        static::assertInstanceOf(AndRule::class$rule->getPayload());

        static::assertCount(2, $rule->getPayload()->getRules());
        static::assertContainsOnlyInstancesOf(OrRule::class$rule->getPayload()->getRules());
    }

    public function testIndexWithRootRuleNotAndRule(): void
    {
        $id = Uuid::randomHex();
        $currencyId1 = Uuid::randomHex();
        $currencyId2 = Uuid::randomHex();

        $data = [
            'id' => $id,
            'name' => 'test rule',
            
$this->expectException(UnknownMigrationSourceException::class);
        $this->expectExceptionMessage('No source registered for "FOOBAR"');
        $this->loader->collect('FOOBAR');
    }

    public function testTheInterfaceNew(): void
    {
        $collection = $this->loader->collect('core');

        static::assertInstanceOf(MigrationCollection::class$collection);
        static::assertSame('core', $collection->getName());
        static::assertContainsOnlyInstancesOf(MigrationStep::class$collection->getMigrationSteps());
        static::assertCount(0, $collection->getMigrationSteps());

        $collection = $this->loader->collect('core.V6_3');
        static::assertInstanceOf(MigrationCollection::class$collection);
        static::assertSame('core.V6_3', $collection->getName());
        static::assertContainsOnlyInstancesOf(MigrationStep::class$collection->getMigrationSteps());
        static::assertGreaterThan(1, \count($collection->getMigrationSteps()));
    }

    public function testItLoadsTheValidMigrations(): void
    {
        
$definition->getDeriver()->willReturn(TestDerivativeDiscoveryWithObject::class);
    $definitions['non_container_aware_discovery'] = $definition->reveal();

    $this->discoveryMain->expects($this->any())
      ->method('getDefinitions')
      ->willReturn($definitions);

    $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
    $definitions = $discovery->getDefinitions();

    // Ensure that both test derivatives got added.     $this->assertContainsOnlyInstancesOf(DerivablePluginDefinitionInterface::class$definitions);
    $this->assertEquals(['non_container_aware_discovery:test_discovery_0', 'non_container_aware_discovery:test_discovery_1']array_keys($definitions));
  }

  /** * @covers ::getDeriverClass */
  public function testGetDeriverClassWithInvalidClassedDefinitions() {
    $definition = $this->prophesize(DerivablePluginDefinitionInterface::class);
    $definition->id()->willReturn('non_existent_discovery');
    $definition->getDeriver()->willReturn('\Drupal\system\Tests\Plugin\NonExistentDeriver');

    
public function testConstruct()
    {
        $type = new Type('object', true, 'ArrayObject', true, new Type('int')new Type('string'));

        $this->assertEquals(Type::BUILTIN_TYPE_OBJECT, $type->getBuiltinType());
        $this->assertTrue($type->isNullable());
        $this->assertEquals('ArrayObject', $type->getClassName());
        $this->assertTrue($type->isCollection());

        $collectionKeyTypes = $type->getCollectionKeyTypes();
        $this->assertIsArray($collectionKeyTypes);
        $this->assertContainsOnlyInstancesOf('Symfony\Component\PropertyInfo\Type', $collectionKeyTypes);
        $this->assertEquals(Type::BUILTIN_TYPE_INT, $collectionKeyTypes[0]->getBuiltinType());

        $collectionValueTypes = $type->getCollectionValueTypes();
        $this->assertIsArray($collectionValueTypes);
        $this->assertContainsOnlyInstancesOf('Symfony\Component\PropertyInfo\Type', $collectionValueTypes);
        $this->assertEquals(Type::BUILTIN_TYPE_STRING, $collectionValueTypes[0]->getBuiltinType());
    }

    public function testIterable()
    {
        $type = new Type('iterable');
        

        $data = $this->createTestCrawler()->filterXPath('//ul[1]/li')->each(fn ($node$i) => $i.'-'.$node->text());

        $this->assertEquals(['0-One', '1-Two', '2-Three']$data, '->each() executes an anonymous function on each node of the list');
    }

    public function testIteration()
    {
        $crawler = $this->createTestCrawler()->filterXPath('//li');

        $this->assertInstanceOf(\Traversable::class$crawler);
        $this->assertContainsOnlyInstancesOf('DOMElement', iterator_to_array($crawler), 'Iterating a Crawler gives DOMElement instances');
    }

    public function testSlice()
    {
        $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
        $this->assertNotSame($crawler->slice()$crawler, '->slice() returns a new instance of a crawler');
        $this->assertInstanceOf(Crawler::class$crawler->slice(), '->slice() returns a new instance of a crawler');

        $this->assertCount(3, $crawler->slice(), '->slice() does not slice the nodes in the list if any param is entered');
        $this->assertCount(1, $crawler->slice(1, 1), '->slice() slices the nodes in the list');
    }

    
null,
                    new Criteria(),
                    $this->context->getContext()
                )
            );

        $this->validator->expects(static::once())
            ->method('validate')
            ->willReturnCallback(function Darray $data, DataValidationDefinition $definition): void {
                $properties = $definition->getProperties();
                static::assertArrayHasKey('doubleOptInRegistration', $properties);
                static::assertContainsOnlyInstancesOf(IsTrue::class$properties['doubleOptInRegistration']);

                static::assertFalse($data['doubleOptInRegistration']);

                throw new ConstraintViolationException(new ConstraintViolationList()$data);
            });

        static::expectException(ConstraintViolationException::class);
        $this->route->confirm($this->mockRequestDataBag()$this->context);
    }

    public function testConfirmActivatedCustomer(): void
    {
/** * @internal */
class EntityDefinitionTest extends TestCase
{
    use KernelTestBehaviour;

    public function testEntityDefinitionCompilation(): void
    {
        $definition = $this->getContainer()->get(ProductDefinition::class);

        static::assertContainsOnlyInstancesOf(Field::class$definition->getFields());
        $productManufacturerVersionIdField = $definition->getFields()->get('productManufacturerVersionId');
        static::assertInstanceOf(ReferenceVersionField::class$productManufacturerVersionIdField);
        static::assertSame('product_manufacturer_version_id', $productManufacturerVersionIdField->getStorageName());
        static::assertInstanceOf(ProductManufacturerDefinition::class$productManufacturerVersionIdField->getVersionReferenceDefinition());
        static::assertSame($this->getContainer()->get(ProductManufacturerDefinition::class)$productManufacturerVersionIdField->getVersionReferenceDefinition());
    }

    public function testTranslationCompilation(): void
    {
        $definition = $this->getContainer()->get(ProductTranslationDefinition::class);

        

  public function testGetDefinitions() {
    $expected = [
      'module_a_provided_layout',
      'theme_a_provided_layout',
      'plugin_provided_layout',
    ];

    $layout_definitions = $this->layoutPluginManager->getDefinitions();
    $this->assertEquals($expectedarray_keys($layout_definitions));
    $this->assertContainsOnlyInstancesOf(LayoutDefinition::class$layout_definitions);
  }

  /** * @covers ::getDefinition * @covers ::processDefinition */
  public function testGetDefinition() {
    $layout_definition = $this->layoutPluginManager->getDefinition('theme_a_provided_layout');
    $this->assertSame('theme_a_provided_layout', $layout_definition->id());
    $this->assertSame('2 column layout', (string) $layout_definition->getLabel());
    $this->assertSame('Columns: 2', (string) $layout_definition->getCategory());
    
$bar_config_object->getCacheMaxAge()->willReturn(Cache::PERMANENT);
    $bar_config_object->getName()->willReturn('foo');

    $this->configFactory->listAll('the_provider.the_config_prefix.')
      ->willReturn(['the_provider.the_config_prefix.foo', 'the_provider.the_config_prefix.bar']);
    $this->configFactory->loadMultiple(['the_provider.the_config_prefix.foo', 'the_provider.the_config_prefix.bar'])
      ->willReturn([$foo_config_object->reveal()$bar_config_object->reveal()]);

    $entities = $this->entityStorage->loadMultiple();
    $expected['foo'] = 'foo';
    $expected['bar'] = 'bar';
    $this->assertContainsOnlyInstancesOf(EntityInterface::class$entities);
    foreach ($entities as $id => $entity) {
      $this->assertSame($id$entity->id());
      $this->assertSame($expected[$id]$entity->id());
    }
  }

  /** * @covers ::loadMultiple * @covers ::postLoad * @covers ::mapFromStorageRecords * @covers ::doLoadMultiple */
Home | Imprint | This part of the site doesn't use cookies.