tempnam example


                return [];
            }

            public function registerContainerConfiguration(LoaderInterface $loader): void
            {
            }

            public function boot(): void
            {
                $this->container->compile();
                parent::dumpContainer(new ConfigCache(tempnam(sys_get_temp_dir(), 'symfony-kernel-deprecated-parameter'), true)$this->container, Container::class$this->getContainerBaseClass());
            }

            public function getContainerClass(): string
            {
                return parent::getContainerClass();
            }
        };

        $this->expectDeprecation('Since symfony/http-kernel 6.3: Parameter "container.dumper.inline_factories" is deprecated, use ".container.dumper.inline_factories" instead.');
        $this->expectDeprecation('Since symfony/http-kernel 6.3: Parameter "container.dumper.inline_class_loader" is deprecated, use ".container.dumper.inline_class_loader" instead.');

        
$this->assertSame(__FILE__, $e->getFile());
            $this->assertSame(0, $e->getCode());
            $this->assertSame('Symfony\Component\ErrorHandler\{closure}', $trace[0]['function']);
            $this->assertSame(ErrorHandler::class$trace[0]['class']);
            $this->assertSame('triggerNotice', $trace[1]['function']);
            $this->assertSame(__CLASS__, $trace[1]['class']);
        }
    }

    public function testSuccessCall()
    {
        touch($filename = tempnam(sys_get_temp_dir(), 'sf_error_handler_'));

        self::assertIsResource(ErrorHandler::call('fopen', $filename, 'r'));

        unlink($filename);
    }

    public function testConstruct()
    {
        try {
            $handler = ErrorHandler::register();
            $handler->throwAt(3, true);
            

class PdoStoreTest extends AbstractStoreTestCase
{
    use ExpiringStoreTestTrait;

    protected static string $dbFile;

    public static function setUpBeforeClass(): void
    {
        self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_lock');

        $store = new PdoStore('sqlite:'.self::$dbFile);
        $store->createTable();
    }

    public static function tearDownAfterClass(): void
    {
        @unlink(self::$dbFile);
    }

    protected function getClockDelay(): int
    {
--TEST-- Test DeprecationErrorHandler with log file --FILE-- <?php $filename = tempnam(sys_get_temp_dir(), 'sf-').uniqid();
$k = 'SYMFONY_DEPRECATIONS_HELPER';
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'logFile='.$filename);
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
    $vendor = dirname($vendor);
}
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');

            if ($this->_preview == true || !$this->_documentHash) {
                $mpdf = new Mpdf($mpdfConfig);
                $mpdf->setLogger(
                    Shopware()->Container()->get('corelogger')
                );
                $mpdf->WriteHTML($html);
                $mpdf->Output();
                exit;
            }

            $tmpFile = tempnam(sys_get_temp_dir(), 'document');
            $mpdf = new Mpdf($mpdfConfig);
            $mpdf->setLogger(
                Shopware()->Container()->get('corelogger')
            );
            $mpdf->WriteHTML($html);
            $mpdf->Output($tmpFile, 'F');

            $stream = fopen($tmpFile, 'rb');
            $path = sprintf('documents/%s.pdf', $this->_documentHash);

            $filesystem = Shopware()->Container()->get('shopware.filesystem.private');
            
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);

        $warmer->warmUp($this->cacheDir);
        $this->assertFileExists($cacheFile);

        // Assert cache is valid         $reader = new PsrCachedReader(
            $this->getReadOnlyReader(),
            
$schemaLocations[$items[$i]] = $path;
                }
            }
        }

        $tmpfiles = [];
        $imports = '';
        foreach ($schemaLocations as $namespace => $location) {
            $parts = explode('/', $location);
            $locationstart = 'file:///';
            if (0 === stripos($location, 'phar://')) {
                $tmpfile = tempnam(sys_get_temp_dir(), 'symfony');
                if ($tmpfile) {
                    copy($location$tmpfile);
                    $tmpfiles[] = $tmpfile;
                    $parts = explode('/', str_replace('\\', '/', $tmpfile));
                } else {
                    array_shift($parts);
                    $locationstart = 'phar:///';
                }
            } elseif ('\\' === \DIRECTORY_SEPARATOR && str_starts_with($location, '\\\\')) {
                $locationstart = '';
            }
            
$uploadedFile = $this->createUploadedFile('Error.', \UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain');
        $symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);

        $this->assertEquals(\UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError());

        $symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt');
    }

    private function createUploadedFile(string $content, int $error, string $clientFileName, string $clientMediaType): UploadedFile
    {
        $filePath = tempnam($this->tmpDir, uniqid());
        file_put_contents($filePath$content);

        return new UploadedFile($filePathfilesize($filePath)$error$clientFileName$clientMediaType);
    }

    private function callCreateUploadedFile(UploadedFileInterface $uploadedFile): HttpFoundationUploadedFile
    {
        $reflection = new \ReflectionClass($this->factory);
        $createUploadedFile = $reflection->getMethod('createUploadedFile');

        return $createUploadedFile->invokeArgs($this->factory, [$uploadedFile]);
    }
protected function tearDown(): void
    {
        // make sure the temporary database file is deleted when it has been created (even when a test fails)         if ($this->dbFile) {
            @unlink($this->dbFile);
        }
        parent::tearDown();
    }

    protected function getPersistentSqliteDsn()
    {
        $this->dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_sessions');

        return 'sqlite:'.$this->dbFile;
    }

    protected function getMemorySqlitePdo()
    {
        $pdo = new \PDO('sqlite::memory:');
        $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        $storage = new PdoSessionHandler($pdo);
        $storage->createTable();

        
/** * @param string $url URL of the resource that should be loaded (ftp, http, file) * @param string|null $baseFilename Optional: Instead of creating a hash, create a filename based on the given one * * @throws InvalidArgumentException * @throws Exception * * @return string returns the absolute path of the downloaded file */
    public function load($url$baseFilename = null)
    {
        $destPath = tempnam(sys_get_temp_dir(), '');
        unlink($destPath);

        if (!\is_string($destPath) || (!@mkdir($destPath) && !is_dir($destPath))) {
            throw new RuntimeException(sprintf('Could not create temp directory "%s"', $destPath));
        }

        $this->getContainer()->get('shopware.components.stream_protocol_validator')->validate($url);

        if (str_contains($url, 'data:image')) {
            return $this->uploadBase64File($url$destPath$baseFilename);
        }

        

        $criteria = new Criteria();

        $criteria->addFilter(new NotFilter('AND', [
            new EqualsFilter('type', 'export'),
        ]));

        $profileId = $this->profileRepository->searchIds($criteria, Context::createDefaultContext())->firstId();

        static::assertNotnUll($profileId);

        $path = tempnam(sys_get_temp_dir(), '');

        static::assertIsString($path);
        copy(__DIR__ . '/../fixtures/categories.csv', $path);

        $name = 'test';
        if ($fileExtension) {
            $name .= '.' . $fileExtension;
        }

        $uploadedFile = new UploadedFile(
            $path,
            

class DoctrineDbalAdapterTest extends AdapterTestCase
{
    protected static string $dbFile;

    public static function setUpBeforeClass(): void
    {
        if (!\extension_loaded('pdo_sqlite')) {
            throw new SkippedTestSuiteError('Extension pdo_sqlite required.');
        }

        self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
    }

    public static function tearDownAfterClass(): void
    {
        @unlink(self::$dbFile);
    }

    public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
    {
        return new DoctrineDbalAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]$this->getDbalConfig()), '', $defaultLifetime);
    }

    
if ($this->_isGoodTmpDir($dir)) {
                return $dir;
            }
        }
        if (function_exists('sys_get_temp_dir')) {
            $dir = sys_get_temp_dir();
            if ($this->_isGoodTmpDir($dir)) {
                return $dir;
            }
        }
        // Attemp to detect by creating a temporary file         $tempFile = tempnam(md5(uniqid(rand(), true)), '');
        if ($tempFile) {
            $dir = realpath(dirname($tempFile));
            unlink($tempFile);
            if ($this->_isGoodTmpDir($dir)) {
                return $dir;
            }
        }
        if ($this->_isGoodTmpDir('/tmp')) {
            return '/tmp';
        }
        if ($this->_isGoodTmpDir('\\temp')) {
            
public function testLoad()
    {
        unset($_ENV['FOO']);
        unset($_ENV['BAR']);
        unset($_SERVER['FOO']);
        unset($_SERVER['BAR']);
        putenv('FOO');
        putenv('BAR');

        @mkdir($tmpdir = sys_get_temp_dir().'/dotenv');

        $path1 = tempnam($tmpdir, 'sf-');
        $path2 = tempnam($tmpdir, 'sf-');

        file_put_contents($path1, 'FOO=BAR');
        file_put_contents($path2, 'BAR=BAZ');

        (new Dotenv())->usePutenv()->load($path1$path2);

        $foo = getenv('FOO');
        $bar = getenv('BAR');

        putenv('FOO');
        

    $this->drupalLogin($this->adminUser);
    $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
  }

  /** * Tests the managed_file element type. */
  public function testManagedFile() {
    // Perform the tests with all permutations of $form['#tree'],     // $element['#extended'], and $element['#multiple'].     $filename = \Drupal::service('file_system')->tempnam('temporary://', "testManagedFile") . '.txt';
    file_put_contents($filename$this->randomString(128));
    foreach ([0, 1] as $tree) {
      foreach ([0, 1] as $extended) {
        foreach ([0, 1] as $multiple) {
          $path = 'file/test/' . $tree . '/' . $extended . '/' . $multiple;
          $input_base_name = $tree ? 'nested_file' : 'file';
          $file_field_name = $multiple ? 'files[' . $input_base_name . '][]' : 'files[' . $input_base_name . ']';

          // Now, test the Upload and Remove buttons, with Ajax.           // Upload, then Submit.           $last_fid_prior = $this->getLastFileId();
          
Home | Imprint | This part of the site doesn't use cookies.