Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/codeception/codeception/src/Codeception/Subscriber/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/codeception/codeception/src/Codeception/Subscriber/BeforeAfterTest.php
<?php

declare(strict_types=1);

namespace Codeception\Subscriber;

use Codeception\Event\SuiteEvent;
use Codeception\Events;
use Codeception\Test\Test;
use Codeception\Test\TestCaseWrapper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use function call_user_func;
use function is_callable;

class BeforeAfterTest implements EventSubscriberInterface
{
    use Shared\StaticEventsTrait;

    /**
     * @var array<string, string|int[]|string[]>
     */
    protected static array $events = [
        Events::SUITE_BEFORE => 'beforeClass',
        Events::SUITE_AFTER  => ['afterClass', 100]
    ];

    public function beforeClass(SuiteEvent $event): void
    {
        foreach ($event->getSuite()->getTests() as $test) {
            $this->executeMethods($test, $test->getMetadata()->getBeforeClassMethods());
        }
    }

    public function afterClass(SuiteEvent $event): void
    {
        foreach ($event->getSuite()->getTests() as $test) {
            $this->executeMethods($test, $test->getMetadata()->getAfterClassMethods());
        }
    }

    private function executeMethods(Test $test, array $methods): void
    {
        if ($test instanceof TestCaseWrapper) {
            $test = $test->getTestCase();
        }

        foreach ($methods as $method) {
            if (is_callable([$test, $method])) {
                call_user_func([$test, $method]);
            }
        }
    }
}

Spamworldpro Mini