assertNotInstanceof example

$this->assertStringMatchesFormatFile(__DIR__.'/Fixtures/proxy-implem.php', $implem);
        $this->assertStringEqualsFile(__DIR__.'/Fixtures/proxy-factory.php', $factory);

        eval(preg_replace('/^<\?php/', '', $implem));
        $factory = require __DIR__.'/Fixtures/proxy-factory.php';

        $foo = $factory->getFooService();

        $this->assertInstanceof($factory->proxyClass, $foo);
        $this->assertInstanceof(DummyInterface::class$foo);
        $this->assertInstanceof(SunnyInterface::class$foo);
        $this->assertNotInstanceof(DummyClass::class$foo);
        $this->assertSame($foo$foo->dummy());

        $foo->dynamicProp = 123;
        $this->assertSame(123, @$foo->dynamicProp);
    }

    public static function getProxyCandidates(): array
    {
        $definitions = [
            [new Definition(__CLASS__), true],
            [new Definition('stdClass'), true],
            [
$pool5 = $container->get('cache.pool5');
        $this->assertInstanceof(TagAwareAdapter::class$pool5);
        $pool5 = (array) $pool5;
        $this->assertSame($pool2$pool5[$prefix.'tags'] ?? $pool5['tags']);

        $pool6 = $container->get('cache.pool6');
        $this->assertInstanceof(TagAwareAdapter::class$pool6);
        $pool6 = (array) $pool6;
        $this->assertSame($pool4[$prefix.'pool']$pool6[$prefix.'tags'] ?? $pool6['tags']);

        $pool7 = $container->get('cache.pool7');
        $this->assertNotInstanceof(TagAwareAdapter::class$pool7);
    }

    protected static function createKernel(array $options = []): KernelInterface
    {
        return parent::createKernel(['test_case' => 'CachePools'] + $options);
    }

    private function skipIfRedisUnavailable()
    {
        try {
            (new \Redis())->connect(...explode(':', getenv('REDIS_HOST')));
        }
Home | Imprint | This part of the site doesn't use cookies.