withMockedEnums example


    public static function setUpBeforeClass(): void
    {
        // Require the fixture file to allow PHP to be fully aware of the enum existence         require __DIR__.'/Fixtures/ExistingEnumReal.php';

        ClassExistsMock::register(__CLASS__);
    }

    protected function setUp(): void
    {
        ClassExistsMock::withMockedEnums([
            ExistingEnum::class => false,
            'NonExistingEnum' => true,
        ]);
    }

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

    public function testClassExists()
    {
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,
        ]);
    }

    public function testClassExists()
    {
        $this->assertFalse(class_exists(ExistingClass::class));
        $this->assertFalse(class_exists(ExistingClass::class, false));
        $this->assertFalse(class_exists('\\'.ExistingClass::class));
        $this->assertFalse(class_exists('\\'.ExistingClass::class, false));
        $this->assertTrue(class_exists('NonExistingClass'));
        
Home | Imprint | This part of the site doesn't use cookies.