Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 44
PolyfillTestCaseTrait
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 7
110
0.00% covered (danger)
0.00%
0 / 44
 createMock
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 10
 createPartialMock
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 11
 expectException
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
 expectExceptionCode
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
 expectExceptionMessage
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
 expectExceptionMessageMatches
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 expectExceptionMessageRegExp
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
<?php
/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Symfony\Bridge\PhpUnit\Legacy;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
 * This trait is @internal.
 */
trait PolyfillTestCaseTrait
{
    /**
     * @param string|string[] $originalClassName
     *
     * @return MockObject
     */
    protected function createMock($originalClassName)
    {
        $mock = $this->getMockBuilder($originalClassName)
            ->disableOriginalConstructor()
            ->disableOriginalClone()
            ->disableArgumentCloning();
        if (method_exists($mock, 'disallowMockingUnknownTypes')) {
            $mock = $mock->disallowMockingUnknownTypes();
        }
        return $mock->getMock();
    }
    /**
     * @param string|string[] $originalClassName
     * @param string[]        $methods
     *
     * @return MockObject
     */
    protected function createPartialMock($originalClassName, array $methods)
    {
        $mock = $this->getMockBuilder($originalClassName)
            ->disableOriginalConstructor()
            ->disableOriginalClone()
            ->disableArgumentCloning()
            ->setMethods(empty($methods) ? null : $methods);
        if (method_exists($mock, 'disallowMockingUnknownTypes')) {
            $mock = $mock->disallowMockingUnknownTypes();
        }
        return $mock->getMock();
    }
    /**
     * @param string $exception
     *
     * @return void
     */
    public function expectException($exception)
    {
        $property = new \ReflectionProperty(TestCase::class, 'expectedException');
        $property->setAccessible(true);
        $property->setValue($this, $exception);
    }
    /**
     * @param int|string $code
     *
     * @return void
     */
    public function expectExceptionCode($code)
    {
        $property = new \ReflectionProperty(TestCase::class, 'expectedExceptionCode');
        $property->setAccessible(true);
        $property->setValue($this, $code);
    }
    /**
     * @param string $message
     *
     * @return void
     */
    public function expectExceptionMessage($message)
    {
        $property = new \ReflectionProperty(TestCase::class, 'expectedExceptionMessage');
        $property->setAccessible(true);
        $property->setValue($this, $message);
    }
    /**
     * @param string $messageRegExp
     *
     * @return void
     */
    public function expectExceptionMessageMatches($messageRegExp)
    {
        $this->expectExceptionMessageRegExp($messageRegExp);
    }
    /**
     * @param string $messageRegExp
     *
     * @return void
     */
    public function expectExceptionMessageRegExp($messageRegExp)
    {
        $property = new \ReflectionProperty(TestCase::class, 'expectedExceptionMessageRegExp');
        $property->setAccessible(true);
        $property->setValue($this, $messageRegExp);
    }
}