tearDown example

/** * @coversDefaultClass \Drupal\media_library\Plugin\views\field\MediaLibrarySelectForm * @group media_library */
class MediaLibrarySelectFormTest extends UnitTestCase {

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    parent::tearDown();
    $container = new ContainerBuilder();
    \Drupal::setContainer($container);
  }

  /** * @covers ::viewsForm */
  public function testViewsForm(): void {
    $row = new ResultRow();

    $field = $this->getMockBuilder(MediaLibrarySelectForm::class)
      
private string $dumpPath;

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

        $this->dumpPath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_matcher.'.uniqid('CompiledUrlMatcher').'.php';
    }

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

        @unlink($this->dumpPath);
    }

    public function testRedirectPreservesUrlEncoding()
    {
        $collection = new RouteCollection();
        $collection->add('foo', new Route('/foo:bar/'));

        $matcher = $this->generateDumpedMatcher($collection);
        $matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/', 'foo')->willReturn([]);

        
private string $previousTimezone;

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

        $this->previousTimezone = date_default_timezone_get();
    }

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

        date_default_timezone_set($this->previousTimezone);
    }

    /** * @dataProvider provideDateTimes */
    public function testDumpDateTime($time$timezone$xDate$xTimestamp)
    {
        $date = new \DateTime($timenew \DateTimeZone($timezone));

        

        $this->cacheDir = sys_get_temp_dir().'/'.uniqid();
        $fs = new Filesystem();
        $fs->mkdir($this->cacheDir);
        parent::setUp();
    }

    protected function tearDown(): void
    {
        $fs = new Filesystem();
        $fs->remove($this->cacheDir);
        parent::tearDown();
    }

    public function testAnnotationsCacheWarmerWithDebugDisabled()
    {
        file_put_contents($this->cacheDir.'/annotations.map', sprintf('<?php return %s;', var_export([__CLASS__], true)));
        $cacheFile = tempnam($this->cacheDir, __FUNCTION__);
        $reader = new AnnotationReader();

        $this->expectDeprecation('Since symfony/framework-bundle 6.4: The "Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer" class is deprecated without replacement.');
        $warmer = new AnnotationsCacheWarmer($reader$cacheFile);

        


            $this->getContainer()->get('product.repository')
                ->create($products, Context::createDefaultContext());
            $criteria = new Criteria($ids->all());
            $result = $this->getContainer()->get('product.repository')
                ->searchIds($criteria, Context::createDefaultContext());
            static::assertNotNull($result);

            return $ids;
        } catch (\Exception $e) {
            static::tearDown();

            throw $e;
        }
    }

    /** * @depends testIndexing */
    public function testCalculator(IdsCollection $ids): void
    {
        try {
            
// Clean FileCache cache.     FileCache::reset();

    // Clean up statics, container, and settings.     if (function_exists('drupal_static_reset')) {
      drupal_static_reset();
    }
    \Drupal::unsetContainer();
    $this->container = NULL;
    new Settings([]);

    parent::tearDown();
  }

  /** * @after * * Additional tear down method to close the connection at the end. */
  public function tearDownCloseDatabaseConnection() {
    // Destroy the database connection, which for example removes the memory     // from sqlite in memory.     foreach (Database::getAllConnectionInfo() as $key => $targets) {
      
$this->container->setParameter('profiler.class', [Profiler::class]);
        $this->container->register('profiler', $profiler::class)
            ->setPublic(true)
            ->addArgument(new Definition($profilerStorage::class));
        $this->container->setParameter('data_collector.templates', []);
        $this->container->set('kernel', $this->kernel);
        $this->container->addCompilerPass(new RegisterListenersPass());
    }

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

        $this->container = null;
    }

    /** * @dataProvider getDebugModes */
    public function testDefaultConfig($debug)
    {
        $this->container->setParameter('kernel.debug', $debug);

        
$this->routeCollection = new RouteCollection();
        $this->generatorDumper = new CompiledUrlGeneratorDumper($this->routeCollection);
        $this->testTmpFilepath = sys_get_temp_dir().'/php_generator.'.$this->getName().'.php';
        $this->largeTestTmpFilepath = sys_get_temp_dir().'/php_generator.'.$this->getName().'.large.php';
        @unlink($this->testTmpFilepath);
        @unlink($this->largeTestTmpFilepath);
    }

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

        @unlink($this->testTmpFilepath);
    }

    public function testDumpWithRoutes()
    {
        $this->routeCollection->add('Test', new Route('/testing/{foo}'));
        $this->routeCollection->add('Test2', new Route('/testing2'));

        file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());

        
/** * @coversDefaultClass \Drupal\comment\Plugin\views\field\CommentBulkForm * @group comment */
class CommentBulkFormTest extends UnitTestCase {

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    parent::tearDown();
    $container = new ContainerBuilder();
    \Drupal::setContainer($container);
  }

  /** * Tests the constructor assignment of actions. */
  public function testConstructor() {
    $actions = [];

    for ($i = 1; $i <= 2; $i++) {
      
public function testProjectDirExtension()
    {
        $kernel = new CustomProjectDirKernel();
        $kernel->boot();

        $this->assertSame(__DIR__.'/Fixtures', $kernel->getProjectDir());
        $this->assertSame(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', $kernel->getContainer()->getParameter('kernel.project_dir'));
    }

    public function testKernelReset()
    {
        $this->tearDown();

        $kernel = new CustomProjectDirKernel();
        $kernel->boot();

        $containerClass = $kernel->getContainer()::class;
        $containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
        unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');

        $kernel = new CustomProjectDirKernel();
        $kernel->boot();

        
protected function tearDown(): void {
    // Destruct the registered backend, each test will get a fresh instance,     // properly emptying it here ensure that on persistent data backends they     // will come up empty the next test.     foreach ($this->cachebackends as $bin => $cachebackend) {
      $this->cachebackends[$bin]->deleteAll();
    }
    unset($this->cachebackends);

    $this->tearDownCacheBackend();

    parent::tearDown();
  }

  /** * Tests the get and set methods of Drupal\Core\Cache\CacheBackendInterface. */
  public function testSetGet() {
    $backend = $this->getCacheBackend();

    $this->assertFalse($backend->get('test1'), "Backend does not contain data for cache id test1.");
    $with_backslash = ['foo' => '\Drupal\foo\Bar'];
    $backend->set('test1', $with_backslash);
    
private string|false $colSize;

    protected function setUp(): void
    {
        $this->colSize = getenv('COLUMNS');
        putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
        parent::setUp();
    }

    protected function tearDown(): void
    {
        parent::tearDown();
        putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
    }

    public function testPushNewMessages()
    {
        $arrayLoader = new ArrayLoader();
        $xliffLoader = new XliffFileLoader();
        $locales = ['en', 'fr'];
        $domains = ['messages'];

        // Simulate existing messages on Provider
      $connection_info['prefix'] = $prefix . '0';
    }

    Database::addConnectionInfo('migrate_drupal_ui', 'default', $connection_info);
  }

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    Database::removeConnection('migrate_drupal_ui');
    parent::tearDown();
  }

  /** * Gets the source base path for the concrete test. * * @return string * The source base path. */
  abstract protected function getSourceBasePath();

  /** * Gets the expected number of entities per entity type after migration. * * @return int[] * An array of expected counts keyed by entity type ID. */
private string $defaultLocale;

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

        $this->defaultLocale = \Locale::getDefault();
    }

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

        \Locale::setDefault($this->defaultLocale);
    }

    protected function createValidator(): CurrencyValidator
    {
        return new CurrencyValidator();
    }

    public function testNullIsValid()
    {
        
EOF;
        $this->connection->executeStatement($nullableTable);
        $this->connection->beginTransaction();
    }

    protected function tearDown(): void
    {
        $this->connection->rollBack();
        $this->connection->executeStatement('DROP TABLE `_date_field_test`');

        parent::tearDown();
    }

    public function testDateFieldIsNullableAndFormat(): void
    {
        $id = Uuid::randomHex();
        $context = $this->createWriteContext();

        $date = new \DateTime();

        $data = [
            'id' => $id,
            
Home | Imprint | This part of the site doesn't use cookies.