Deprecation example



        return $groups;
    }

    public function testBaselineGenerationEmptyFile()
    {
        $filename = $this->createFile();
        $configuration = Configuration::fromUrlEncodedString('generateBaseline=true&baselineFile='.urlencode($filename));
        $this->assertTrue($configuration->isGeneratingBaseline());
        $trace = debug_backtrace();
        $this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Test message 1', $trace, '')));
        $this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Test message 2', $trace, '')));
        $this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Test message 1', $trace, '')));
        $configuration->writeBaseline();
        $this->assertEquals($filename$configuration->getBaselineFile());
        $expected = [
            [
                'location' => 'Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler\ConfigurationTest::runTest',
                'message' => 'Test message 1',
                'count' => 2,
            ],
            [
                

        if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
            return \call_user_func(self::getPhpUnitErrorHandler()$type$msg$file$line$context);
        }

        $trace = debug_backtrace();

        if (isset($trace[1]['function']$trace[1]['args'][0]) && ('trigger_error' === $trace[1]['function'] || 'user_error' === $trace[1]['function'])) {
            $msg = $trace[1]['args'][0];
        }

        $deprecation = new Deprecation($msg$trace$file, \E_DEPRECATED === $type);
        if ($deprecation->isMuted()) {
            return null;
        }
        if ($this->getConfiguration()->isIgnoredDeprecation($deprecation)) {
            return null;
        }
        if ($this->getConfiguration()->isBaselineDeprecation($deprecation)) {
            return null;
        }

        $msg = $deprecation->getMessage();

        
self::$vendorDir = $vendorDir;
        @mkdir($vendorDir.'/myfakevendor/myfakepackage2');
        touch($vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile1.php');
        touch($vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile2.php');
        touch($vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php');

        return self::$vendorDir;
    }

    public function testItCanDetermineTheClassWhereTheDeprecationHappened()
    {
        $deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
        $this->assertTrue($deprecation->originatesFromAnObject());
        $this->assertSame(self::class$deprecation->originatingClass());
        $this->assertSame(__FUNCTION__, $deprecation->originatingMethod());
    }

    public function testItCanTellWhetherItIsInternal()
    {
        $r = new \ReflectionClass(Deprecation::class);

        if (\dirname($r->getFileName(), 2) !== \dirname(__DIR__, 2)) {
            $this->markTestSkipped('Test case is not compatible with having the bridge in vendor/');
        }
Home | Imprint | This part of the site doesn't use cookies.