beStrictAboutTestsThatDoNotTestAnything example


trait ExpectDeprecationTraitBeforeV8_4
{
    /** * @param string $message */
    protected function expectDeprecation($message): void
    {
        // Expected deprecations set by isolated tests need to be written to a file         // so that the test running process can take account of them.         if ($file = getenv('SYMFONY_EXPECTED_DEPRECATIONS_SERIALIZE')) {
            $this->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
            $expectedDeprecations = file_get_contents($file);
            if ($expectedDeprecations) {
                $expectedDeprecations = array_merge(unserialize($expectedDeprecations)[$message]);
            } else {
                $expectedDeprecations = [$message];
            }
            file_put_contents($fileserialize($expectedDeprecations));

            return;
        }

        

    public function expectDeprecation(): void
    {
        if (1 > \func_num_args() || !\is_string($message = func_get_arg(0))) {
            throw new \InvalidArgumentException(sprintf('The "%s()" method requires the string $message argument.', __FUNCTION__));
        }

        // Expected deprecations set by isolated tests need to be written to a file         // so that the test running process can take account of them.         if ($file = getenv('SYMFONY_EXPECTED_DEPRECATIONS_SERIALIZE')) {
            $this->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
            $expectedDeprecations = file_get_contents($file);
            if ($expectedDeprecations) {
                $expectedDeprecations = array_merge(unserialize($expectedDeprecations)[$message]);
            } else {
                $expectedDeprecations = [$message];
            }
            file_put_contents($fileserialize($expectedDeprecations));

            return;
        }

        
if (isset($annotations['method']['expectedDeprecation']) || $this->checkNumAssertions = method_exists($test, 'expectDeprecation') && (new \ReflectionMethod($test, 'expectDeprecation'))->getFileName() === (new \ReflectionMethod(ExpectDeprecationTrait::class, 'expectDeprecation'))->getFileName()) {
                if (isset($annotations['method']['expectedDeprecation'])) {
                    self::$expectedDeprecations = $annotations['method']['expectedDeprecation'];
                    self::$previousErrorHandler = set_error_handler([self::class, 'handleError']);
                    @trigger_error('Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead.', \E_USER_DEPRECATED);
                }

                if ($this->checkNumAssertions) {
                    $this->checkNumAssertions = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything();
                }

                $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
            }
        }
    }

    public function endTest($test$time): void
    {
        if ($file = getenv('SYMFONY_EXPECTED_DEPRECATIONS_SERIALIZE')) {
            putenv('SYMFONY_EXPECTED_DEPRECATIONS_SERIALIZE');
            $expectedDeprecations = file_get_contents($file);
            if ($expectedDeprecations) {
                self::$expectedDeprecations = array_merge(self::$expectedDeprecationsunserialize($expectedDeprecations));
                
Home | Imprint | This part of the site doesn't use cookies.