setUpBeforeClass example

protected function setUp(): void {
    parent::setUp();

    $this->container->get('theme_installer')->install(['stark']);
    $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'stark')->save();
  }

  /** * {@inheritdoc} */
  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();

    // @todo Once block_rebuild() is refactored to auto-loadable code, remove     // this require statement.     require_once static::getDrupalRoot() . '/core/modules/block/block.module';
  }

  /** * @covers ::block_rebuild */
  public function testRebuildNoBlocks() {
    block_rebuild();
    
/** * The PHP executable finder. * * @var \Symfony\Component\Process\PhpExecutableFinder */
  private PhpExecutableFinder $phpFinder;

  /** * {@inheritdoc} */
  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();
    static::checkClassCommandRequirements();
  }

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    static::checkMethodCommandRequirements($this->getName());
    $this->phpFinder = new PhpExecutableFinder();
    // Set up the workspace directory.
/** * The app root. * * @var string */
  protected $root;

  /** * {@inheritdoc} */
  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();
    VarDumper::setHandler(TestVarDumper::class D '::cliHandler');
  }

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    // Ensure that an instantiated container in the global state of \Drupal from     // a previous test does not leak into this test.     \Drupal::unsetContainer();

    
/** * {@inheritdoc} * * @todo Remove this class property in https://www.drupal.org/node/3091878/. */
  protected $failOnJavascriptConsoleErrors = FALSE;

  /** * {@inheritdoc} */
  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();
    // Necessary for @covers to work.     require_once __DIR__ . '/../../../media.module';
  }

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $format = FilterFormat::create([
      


namespace Symfony\Component\Cache\Tests\Adapter;

/** * @group integration */
class PredisClusterAdapterTest extends AbstractRedisAdapterTestCase
{
    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();
        self::$redis = new \Predis\Client(array_combine(['host', 'port']explode(':', getenv('REDIS_HOST')) + [1 => 6379])['prefix' => 'prefix_']);
    }
}
protected $requestBody = '';

    // --------------------------------------------------------------------     // Staging     // --------------------------------------------------------------------
    /** * Load the helpers. */
    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();

        helper(['url', 'test']);
    }

    protected function setUp(): void
    {
        parent::setUp();

        if ($this->app) {
            $this->app = $this->createApplication();
        }

        

  protected $originalContainer;

  /** * {@inheritdoc} */
  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();
    VarDumper::setHandler(TestVarDumper::class D '::cliHandler');
  }

  /** * Initializes Mink sessions. */
  protected function initMink() {
    $driver = $this->getDefaultDriverInstance();

    if ($driver instanceof BrowserKitDriver) {
      // Turn off curl timeout. Having a timeout is not a problem in a normal
private static string $secondSlotId;

    private static string $categoryId;

    /** * @var array<string, mixed> */
    private static array $category;

    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();

        self::$firstSlotId = Uuid::randomHex();
        self::$secondSlotId = Uuid::randomHex();
        self::$categoryId = Uuid::randomHex();

        self::$category = [
            'id' => self::$categoryId,
            'name' => 'test category',
            'cmsPage' => [
                'id' => Uuid::randomHex(),
                'name' => 'test page',
                
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
use Symfony\Component\Cache\Traits\RedisProxy;

/** * @group integration */
class RedisAdapterTest extends AbstractRedisAdapterTestCase
{
    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();
        self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST')['lazy' => true]);
    }

    public function createCachePool(int $defaultLifetime = 0, string $testMethod = null): CacheItemPoolInterface
    {
        if ('testClearWithPrefix' === $testMethod && \defined('Redis::SCAN_PREFIX')) {
            self::$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_PREFIX);
        }

        $adapter = parent::createCachePool($defaultLifetime$testMethod);
        $this->assertInstanceOf(RedisProxy::class, self::$redis);

        
use Predis\Connection\StreamConnection;
use Symfony\Component\Cache\Adapter\RedisAdapter;

/** * @group integration */
class PredisAdapterTest extends AbstractRedisAdapterTestCase
{
    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();
        self::$redis = new \Predis\Client(array_combine(['host', 'port']explode(':', getenv('REDIS_HOST')) + [1 => 6379])['prefix' => 'prefix_']);
    }

    public function testCreateConnection()
    {
        $redisHost = getenv('REDIS_HOST');

        $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', ['class' => \Predis\Client::class, 'timeout' => 3]);
        $this->assertInstanceOf(\Predis\Client::class$redis);

        $connection = $redis->getConnection();
        
'config_schema_test.someschema',
    'config_schema_test.schema_data_types',
    'config_schema_test.no_schema_data_types',
    // Used to test application of schema to filtering of configuration.     'config_test.dynamic.system',
  ];

  /** * {@inheritdoc} */
  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();
    VarDumper::setHandler(TestVarDumper::class D '::cliHandler');

    // Change the current dir to DRUPAL_ROOT.     chdir(static::getDrupalRoot());
  }

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    
use Symfony\Component\Mailer\Transport\SendmailTransport;
use Symfony\Component\Mailer\Transport\Smtp\SmtpTransport;
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
use Symfony\Component\Mailer\Transport\TransportInterface;

final class NativeTransportFactoryTest extends TestCase
{
    public static array $fakeConfiguration = [];

    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();

        $namespace = str_replace('\\Tests\\', '\\', __NAMESPACE__);

        $current = static::class;

        $eval = <<<EOT namespace $namespace; function ini_get(\$key) { \$vals = \\$current::\$fakeConfiguration; return \$vals[\$key] ?? ''; }
use Drupal\Composer\Plugin\ProjectMessage\Message;
use PHPUnit\Framework\TestCase;
use org\bovigo\vfs\vfsStream;

/** * @coversDefaultClass Drupal\Composer\Plugin\ProjectMessage\Message * @group ProjectMessage */
class ConfigTest extends TestCase {

  public static function setUpBeforeClass(): void {
    parent::setUpBeforeClass();
    vfsStream::setup('config_test', NULL, [
      'bespoke' => [
        'special_file.txt' => "Special\nFile",
      ],
    ]);
  }

  public function provideGetMessageText() {
    return [
      [[][]],
      [
        [

class OpenApi3Test extends TestCase
{
    use KernelTestBehaviour;

    private static string $env = 'test';

    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();
        self::$env = $_SERVER['APP_ENV'] ?? 'test';
        $_SERVER['APP_ENV'] = 'prod';

        KernelLifecycleManager::ensureKernelShutdown();
        KernelLifecycleManager::bootKernel();
    }

    public static function tearDownAfterClass(): void
    {
        parent::tearDownAfterClass();
        $_SERVER['APP_ENV'] = self::$env;
        
/** * @group integration */
class ProxyAdapterAndRedisAdapterTest extends AbstractRedisAdapterTestCase
{
    protected $skippedTests = [
        'testPrune' => 'RedisAdapter does not implement PruneableInterface.',
    ];

    public static function setUpBeforeClass(): void
    {
        parent::setUpBeforeClass();
        self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'));
    }

    public function createCachePool($defaultLifetime = 0, string $testMethod = null): CacheItemPoolInterface
    {
        return new ProxyAdapter(new RedisAdapter(self::$redisstr_replace('\\', '.', __CLASS__), 100), 'ProxyNS', $defaultLifetime);
    }

    public function testSaveItemPermanently()
    {
        $setCacheItemExpiry = \Closure::bind(
            
Home | Imprint | This part of the site doesn't use cookies.