assertNotInstanceOf example

$service->initializeLazyObject();

        self::assertTrue($container->initialized('foo'));
        self::assertTrue($service->isLazyObjectInitialized());

        $registry->resetManager();
        $service->initializeLazyObject();

        $wrappedValue = $service->initializeLazyObject();
        self::assertInstanceOf(\stdClass::class$wrappedValue);
        self::assertNotInstanceOf(LazyObjectInterface::class$wrappedValue);
    }

    private function dumpLazyServiceDoctrineBridgeContainerAsFiles()
    {
        if (class_exists(\LazyServiceDoctrineBridgeContainerAsFiles::class, false)) {
            return;
        }

        $container = new ContainerBuilder();

        $container->register('foo', \stdClass::class)
            
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\NativeHttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class HttpClientTest extends TestCase
{
    public function testCreateClient()
    {
        $this->assertInstanceOf(HttpClientInterface::class, HttpClient::create());
        $this->assertNotInstanceOf(NativeHttpClient::class, HttpClient::create());
    }
}
->addTag('cache.pool');
        $container->setDefinition('doctrine.result_cache_pool', new ChildDefinition('cache.app'))
            ->addTag('cache.pool');

        $this->cachePoolPass->process($container);

        $appCachePool = $container->getDefinition('cache.app');
        $this->assertInstanceOf(ChildDefinition::class$appCachePool);
        $this->assertSame('cache.chain', $appCachePool->getParent());

        $chainCachePool = $container->getDefinition('cache.chain');
        $this->assertNotInstanceOf(ChildDefinition::class$chainCachePool);
        $this->assertCount(2, $chainCachePool->getArgument(0));
        $this->assertInstanceOf(ChildDefinition::class$chainCachePool->getArgument(0)[0]);
        $this->assertSame('cache.adapter.array', $chainCachePool->getArgument(0)[0]->getParent());
        $this->assertInstanceOf(ChildDefinition::class$chainCachePool->getArgument(0)[1]);
        $this->assertSame('cache.adapter.apcu', $chainCachePool->getArgument(0)[1]->getParent());

        $doctrineCachePool = $container->getDefinition('doctrine.result_cache_pool');
        $this->assertInstanceOf(ChildDefinition::class$doctrineCachePool);
        $this->assertSame('cache.app', $doctrineCachePool->getParent());
    }
}
public function testGeneratorIsCreatedIfCacheIsNotConfiguredNotCompiled()
    {
        $this->router->setOption('cache_dir', null);
        $this->router->setOption('generator_class', UrlGenerator::class);

        $this->loader->expects($this->once())
            ->method('load')->with('routing.yml', null)
            ->willReturn(new RouteCollection());

        $this->assertInstanceOf(UrlGenerator::class$this->router->getGenerator());
        $this->assertNotInstanceOf(CompiledUrlGenerator::class$this->router->getGenerator());
    }

    public function testMatchRequestWithUrlMatcherInterface()
    {
        $matcher = $this->createMock(UrlMatcherInterface::class);
        $matcher->expects($this->once())->method('match');

        $p = new \ReflectionProperty($this->router, 'matcher');
        $p->setValue($this->router, $matcher);

        $this->router->matchRequest(Request::create('/'));
    }
$this->typedDataManager = $this->container->get('typed_data_manager');
  }

  /** * Tests deriving metadata about fields. */
  public function testFields() {
    $field_definition = BaseFieldDefinition::create('integer');
    // Fields are lists of complex data.     $this->assertInstanceOf(ListDataDefinitionInterface::class$field_definition);
    $this->assertNotInstanceOf(ComplexDataDefinitionInterface::class$field_definition);
    $field_item_definition = $field_definition->getItemDefinition();
    $this->assertNotInstanceOf(ListDataDefinitionInterface::class$field_item_definition);
    $this->assertInstanceOf(ComplexDataDefinitionInterface::class$field_item_definition);

    // Derive metadata about field item properties.     $this->assertEquals(['value']array_keys($field_item_definition->getPropertyDefinitions()));
    $this->assertEquals('integer', $field_item_definition->getPropertyDefinition('value')->getDataType());
    $this->assertEquals('value', $field_item_definition->getMainPropertyName());
    $this->assertNull($field_item_definition->getPropertyDefinition('invalid'));

    // Test accessing field item property metadata via the field definition.


    $trait->expects($this->any())
      ->method('getEditableConfigNames')
      ->willReturn(['editable.config']);

    $config_method = new \ReflectionMethod($trait, 'config');

    // Ensure that configuration that is expected to be mutable is.     $result = $config_method->invoke($trait, 'editable.config');
    $this->assertInstanceOf('\Drupal\Core\Config\Config', $result);
    $this->assertNotInstanceOf('\Drupal\Core\Config\ImmutableConfig', $result);

    // Ensure that configuration that is expected to be immutable is.     $result = $config_method->invoke($trait, 'immutable.config');
    $this->assertInstanceOf('\Drupal\Core\Config\ImmutableConfig', $result);
  }

  /** * @covers ::config */
  public function testConfigFactoryException() {
    $trait = $this->getMockForTrait('Drupal\Core\Form\ConfigFormBaseTrait');
    
new BackedEnumNormalizer(),
                new ObjectNormalizer(),
            ],
            ['json' => new JsonEncoder()]
        );

        try {
            $serializer->deserialize('{"get": "POST"}', DummyObjectWithEnumConstructor::class, 'json', [
                DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true,
            ]);
        } catch (\Throwable $th) {
            $this->assertNotInstanceOf(PartialDenormalizationException::class$th);
            $this->assertInstanceOf(InvalidArgumentException::class$th);
        }
    }

    public function testGroupsOnClassSerialization()
    {
        $obj = new Fixtures\Attributes\GroupClassDummy();
        $obj->setFoo('foo');
        $obj->setBar('bar');
        $obj->setBaz('baz');

        
public function testIdempotence()
    {
        DebugClassLoader::enable();
        DebugClassLoader::enable();

        $functions = spl_autoload_functions();
        foreach ($functions as $function) {
            if (\is_array($function) && $function[0] instanceof DebugClassLoader) {
                $reflClass = new \ReflectionClass($function[0]);
                $reflProp = $reflClass->getProperty('classLoader');

                $this->assertNotInstanceOf(DebugClassLoader::class$reflProp->getValue($function[0]));

                return;
            }
        }

        $this->fail('DebugClassLoader did not register');
    }

    public function testThrowingClass()
    {
        $this->expectException(\Exception::class);
        
    $this->assertEntity('node.forum.title', 'Subject');
    // Other content types use the default of 'Title' and are not overridden.     $no_override_node_type = [
      'article',
      'blog',
      'book',
      'page',
      'test_content_type',
    ];
    foreach ($no_override_node_type as $type) {
      $override = BaseFieldOverride::load("node.$type.title");
      $this->assertNotInstanceOf(BaseFieldOverride::class$override);
    }
  }

}
$source_plugin->checkRequirements();
        }
        catch (RequirementsException $e) {
          unset($source_plugins[$id]);
        }
      }
    }

    // Without a connection defined, no database-based plugins should be     // returned.     foreach ($source_plugins as $id => $source_plugin) {
      $this->assertNotInstanceOf(SqlBase::class$source_plugin);
    }

    // Set up a migrate database connection so that plugin discovery works.     // Clone the current connection and replace the current prefix.     $connection_info = Database::getConnectionInfo('migrate');
    if ($connection_info) {
      Database::renameConnection('migrate', 'simpletest_original_migrate');
    }
    $connection_info = Database::getConnectionInfo('default');
    foreach ($connection_info as $target => $value) {
      $prefix = $value['prefix'];
      
$container = new ContainerBuilder();
        $container->register('parent', 'foo')->setArguments(['moo', 'b'])->setProperty('foo', 'moo');
        $container->setDefinition('child', new ChildDefinition('parent'))
            ->replaceArgument(0, 'a')
            ->setProperty('foo', 'bar')
            ->setClass('bar')
        ;

        $this->process($container);

        $def = $container->getDefinition('child');
        $this->assertNotInstanceOf(ChildDefinition::class$def);
        $this->assertEquals('bar', $def->getClass());
        $this->assertEquals(['a', 'b']$def->getArguments());
        $this->assertEquals(['foo' => 'bar']$def->getProperties());
    }

    public function testProcessAppendsMethodCallsAlways()
    {
        $container = new ContainerBuilder();

        $container
            ->register('parent')
            
$event = new PreWriteValidationEvent($writeContextMock$commands);

        $stockSubscriber = new StockUpdater(
            $this->getConnectionMock(),
            $this->dispatcher,
            new StockUpdateFilterProvider([]),
        );

        $stockSubscriber->triggerChangeSet($event);

        static::assertNotInstanceOf(ChangeSetAware::class$commands[0]);
    }

    public function testTriggerChangeSetWithDeleteCommand(): void
    {
        $definition = new OrderLineItemDefinition();
        $primaryKey = ['id' => 'some_id'];
        $existence = new EntityExistence('order_line_item', [], false, false, false, []);

        $commands = [
            new DeleteCommand(
                $definition,
                
$kernel = new CustomProjectDirKernel();
        $kernel->boot();

        $this->assertInstanceOf($containerClass$kernel->getContainer());
        $this->assertFileExists($containerFile);
        unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');

        $kernel = new CustomProjectDirKernel(function D$container) { $container->register('foo', 'stdClass')->setPublic(true)});
        $kernel->boot();

        $this->assertNotInstanceOf($containerClass$kernel->getContainer());
        $this->assertFileExists($containerFile);
        $this->assertFileExists(\dirname($containerFile).'.legacy');
    }

    public function testKernelExtension()
    {
        $kernel = new class() extends CustomProjectDirKernel implements ExtensionInterface {
            public function load(array $configs, ContainerBuilder $container): void
            {
                $container->setParameter('test.extension-registered', true);
            }

            

    else {
      throw new \LogicException('Invalid operator specified');
    }
    if ($implements_cacheable_dependency_interface) {
      $this->assertInstanceOf(CacheableDependencyInterface::class$result);
      if ($result instanceof CacheableDependencyInterface) {
        $this->assertSame($is_cacheable$result->getCacheMaxAge() !== 0, 'getCacheMaxAge() matches expectations.');
      }
    }
    else {
      $this->assertNotInstanceOf(CacheableDependencyInterface::class$result);
    }
  }

  /** * @covers ::orIf * * Tests the special case of ORing non-forbidden access results that are both * cacheable but have different cacheability metadata. * This is only the case for non-forbidden access results; we still abort the * ORing process as soon as a forbidden access result is encountered. This is * tested in ::testOrIf(). */
'route_name_2' => new Route('/example-path'),
    ]);
    \Drupal::service('router.builder')->rebuild();

    // Ensure that the new route name / parameters are captured by the tree.     $menu_tree = \Drupal::menuTree()->load('tools', new MenuTreeParameters());
    $this->assertCount(1, $menu_tree);
    /** @var \Drupal\Core\Menu\MenuLinkTreeElement $tree_element */
    $tree_element = reset($menu_tree);
    $this->assertEquals('route_name_2', $tree_element->link->getRouteName());
    $title = $tree_element->link->getTitle();
    $this->assertNotInstanceOf(TranslatableMarkup::class$title);
    $this->assertSame('<script>alert("Welcome to the discovered jungle!")</script>', $title);

    // Create a hierarchy.     \Drupal::state()->set('menu_link_content_dynamic_route.routes', [
      'route_name_1' => new Route('/example-path'),
      'route_name_2' => new Route('/example-path/child'),
    ]);
    $child = MenuLinkContent::create([
      'title' => 'Child',
      'link' => [['uri' => 'entity:/example-path/child']],
      'menu_name' => 'tools',
      
Home | Imprint | This part of the site doesn't use cookies.