withMockedClasses example

$pass = new AutowirePass();
        try {
            $pass->process($container);
            $this->fail('AutowirePass should have thrown an exception');
        } catch (AutowiringFailedException $e) {
            $this->assertMatchesRegularExpression('{^Cannot autowire service "a": argument "\$r" of method "(Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Compiler\\\\)BadParentTypeHintedArgument::__construct\(\)" has type "\1OptionalServiceClass" but this class is missing a parent class \(Class "?Symfony\\\\Bug\\\\NotExistClass"? not found}', (string) $e->getMessage());
        }
    }

    public function testParentClassNotFoundThrowsExceptionWithoutConfigComponent()
    {
        ClassExistsMock::withMockedClasses([
            ClassExistenceResource::class => false,
        ]);

        $container = new ContainerBuilder();

        $aDefinition = $container->register('a', BadParentTypeHintedArgument::class);
        $aDefinition->setAutowired(true);

        $container->register(Dunglas::class, Dunglas::class);

        $pass = new AutowirePass();
        
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
use Symfony\Component\Mailer\Transport\Dsn;

/** * @runTestsInSeparateProcesses */
final class UnsupportedSchemeExceptionTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(__CLASS__);
        ClassExistsMock::withMockedClasses([
            BrevoTransportFactory::class => false,
            GmailTransportFactory::class => false,
            InfobipTransportFactory::class => false,
            MailerSendTransportFactory::class => false,
            MailgunTransportFactory::class => false,
            MailjetTransportFactory::class => false,
            MandrillTransportFactory::class => false,
            OhMySmtpTransportFactory::class => false,
            PostmarkTransportFactory::class => false,
            ScalewayTransportFactory::class => false,
            SendgridTransportFactory::class => false,
            
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClassExistsMock;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\VarDumper\Dumper\CliDumper;

class DumperNativeFallbackTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(Dumper::class);
        ClassExistsMock::withMockedClasses([
            CliDumper::class => false,
        ]);
    }

    public static function tearDownAfterClass(): void
    {
        ClassExistsMock::withMockedClasses([]);
    }

    /** * @dataProvider provideVariables */
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\Dsn;

/** * @runTestsInSeparateProcesses */
final class UnsupportedSchemeExceptionTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(__CLASS__);
        ClassExistsMock::withMockedClasses([
            Bridge\AllMySms\AllMySmsTransportFactory::class => false,
            Bridge\AmazonSns\AmazonSnsTransportFactory::class => false,
            Bridge\Bandwidth\BandwidthTransportFactory::class => false,
            Bridge\Brevo\BrevoTransportFactory::class => false,
            Bridge\Chatwork\ChatworkTransportFactory::class => false,
            Bridge\Clickatell\ClickatellTransportFactory::class => false,
            Bridge\ClickSend\ClickSendTransportFactory::class => false,
            Bridge\ContactEveryone\ContactEveryoneTransportFactory::class => false,
            Bridge\Discord\DiscordTransportFactory::class => false,
            Bridge\Engagespot\EngagespotTransportFactory::class => false,
            Bridge\Esendex\EsendexTransportFactory::class => false,
            
use Symfony\Component\Translation\Exception\UnsupportedSchemeException;
use Symfony\Component\Translation\Provider\Dsn;

/** * @runTestsInSeparateProcesses */
final class UnsupportedSchemeExceptionTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(__CLASS__);
        ClassExistsMock::withMockedClasses([
            CrowdinProviderFactory::class => false,
            LocoProviderFactory::class => false,
            LokaliseProviderFactory::class => false,
        ]);
    }

    /** * @dataProvider messageWhereSchemeIsPartOfSchemeToPackageMapProvider */
    public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme, string $package)
    {
        
use Symfony\Bridge\PhpUnit\ClassExistsMock;

class ClassExistsMockTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(__CLASS__);
    }

    protected function setUp(): void
    {
        ClassExistsMock::withMockedClasses([
            ExistingClass::class => false,
            'NonExistingClass' => true,
            ExistingInterface::class => false,
            'NonExistingInterface' => true,
            ExistingTrait::class => false,
            'NonExistingTrait' => true,
        ]);

        ClassExistsMock::withMockedEnums([
            'NonExistingEnum' => true,
        ]);
    }
Home | Imprint | This part of the site doesn't use cookies.