sys_get_temp_dir example

$this->assertSame($expectedSuggestions$tester->complete($input));
    }

    public static function provideCompletionSuggestions()
    {
        yield 'option' => [['--format', '']['txt', 'json', 'github']];
    }

    private function createFile($content): string
    {
        $filename = tempnam(sys_get_temp_dir().'/framework-yml-lint-test', 'sf-');
        file_put_contents($filename$content);

        $this->files[] = $filename;

        return $filename;
    }

    protected function createCommand(): Command
    {
        $application = new Application();
        $application->add(new LintCommand());

        
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage;
use Symfony\Component\HttpKernel\Profiler\Profile;

class FileProfilerStorageTest extends TestCase
{
    private string $tmpDir;
    private FileProfilerStorage $storage;

    protected function setUp(): void
    {
        $this->tmpDir = sys_get_temp_dir().'/sf_profiler_file_storage';
        if (is_dir($this->tmpDir)) {
            self::cleanDir();
        }
        $this->storage = new FileProfilerStorage('file:'.$this->tmpDir);
        $this->storage->purge();
    }

    protected function tearDown(): void
    {
        self::cleanDir();
    }

    

#[Package('core')] class StreamedCommandResponseGenerator
{
    /** * @param array<string> $params * @param callable(Process): void $finish */
    public function run(array $params, callable $finish): StreamedResponse
    {
        $process = new Process($params);
        $process->setEnv(['COMPOSER_HOME' => sys_get_temp_dir() . '/composer']);
        $process->setTimeout(300);

        $process->start();

        return new StreamedResponse(function D) use ($process$finish): void {
            foreach ($process->getIterator() as $item) {
                \assert(\is_string($item));
                echo $item;
                flush();
            }

            
$extension = $information['extension'] ?? '';
        if ($extension !== 'zip') {
            $this->View()->assign([
                'success' => false,
                'message' => sprintf('Wrong archive extension %s. Zip archive expected', $extension),
            ]);
            unlink($file->getPathname());

            return;
        }

        $tempFileName = tempnam(sys_get_temp_dir()$file->getClientOriginalName());
        $tempDirectory = \dirname(realpath($tempFileName));

        try {
            $file = $file->move($tempDirectory$tempFileName);

            $pluginName = $information['basename'];
            $pluginDownloadService->extractPluginZip($file->getPathname()$pluginName);
        } catch (Exception $e) {
            $this->View()->assign([
                'success' => false,
                'message' => $e->getMessage(),
            ]);


        $container = new ContainerBuilder();

        $container->register('foo', \stdClass::class)
            ->setPublic(true)
            ->setLazy(true);
        $container->compile();

        $fileSystem = new Filesystem();

        $temporaryPath = $fileSystem->tempnam(sys_get_temp_dir(), 'symfonyManagerRegistryTest');
        $fileSystem->remove($temporaryPath);
        $fileSystem->mkdir($temporaryPath);

        $dumper = new PhpDumper($container);

        $dumper->setProxyDumper(new ProxyDumper());
        $containerFiles = $dumper->dump([
            'class' => 'LazyServiceProjectAsFilesServiceContainer',
            'as_files' => true,
        ]);

        

trait FilesystemCommonTrait
{
    private string $directory;
    private string $tmpSuffix;

    private function init(string $namespace, ?string $directory): void
    {
        if (!isset($directory[0])) {
            $directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfony-cache';
        } else {
            $directory = realpath($directory) ?: $directory;
        }
        if (isset($namespace[0])) {
            if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace$match)) {
                throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
            }
            $directory .= \DIRECTORY_SEPARATOR.$namespace;
        } else {
            $directory .= \DIRECTORY_SEPARATOR.'@';
        }
        

class JsonBundleWriterTest extends TestCase
{
    private JsonBundleWriter $writer;
    private string $directory;
    private Filesystem $filesystem;

    protected function setUp(): void
    {
        $this->writer = new JsonBundleWriter();
        $this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.mt_rand(1000, 9999);
        $this->filesystem = new Filesystem();

        $this->filesystem->mkdir($this->directory);
    }

    protected function tearDown(): void
    {
        $this->filesystem->remove($this->directory);
    }

    public function testWrite()
    {
$recoveryManager->getShopwareLocation();
    }

    /** * @backupGlobals enabled */
    public function testGetShopwareLocationFailsDueNonPublicDirectory(): void
    {
        $recoveryManager = new RecoveryManager();

        $fs = new Filesystem();
        $tmpDir = sys_get_temp_dir() . '/' . uniqid('shopware', true);

        $_SERVER['SCRIPT_FILENAME'] = $tmpDir . '/foo/shopware-installer.phar.php';
        $fs->mkdir($tmpDir . '/foo');
        $fs->touch($tmpDir . '/foo/shopware-installer.phar.php');

        static::expectException(\RuntimeException::class);
        static::expectExceptionMessage('Could not find Shopware installation');
        $recoveryManager->getShopwareLocation();

        $fs->remove($tmpDir);
    }

    
class StoreTest extends TestCase
{
    protected Request $request;
    protected Response $response;
    protected Store $store;

    protected function setUp(): void
    {
        $this->request = Request::create('/');
        $this->response = new Response('hello world', 200, []);

        HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache');

        $this->store = new Store(sys_get_temp_dir().'/http_cache');
    }

    protected function tearDown(): void
    {
        HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache');
    }

    public function testReadsAnEmptyArrayWithReadWhenNothingCachedAtKey()
    {
        
class ValidatorCacheWarmerTest extends TestCase
{
    public function testWarmUp()
    {
        $validatorBuilder = new ValidatorBuilder();
        $validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
        $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
        $validatorBuilder->addMethodMapping('loadValidatorMetadata');
        $validatorBuilder->enableAttributeMapping();

        $file = sys_get_temp_dir().'/cache-validator.php';
        @unlink($file);

        $warmer = new ValidatorCacheWarmer($validatorBuilder$file);
        $warmer->warmUp(\dirname($file));

        $this->assertFileExists($file);

        $arrayPool = new PhpArrayAdapter($filenew NullAdapter());

        $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
        $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
    }

        $this->deleteTempDir();
    }

    protected function tearDown(): void
    {
        $this->deleteTempDir();
    }

    protected function deleteTempDir()
    {
        if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel')) {
            return;
        }

        $fs = new Filesystem();
        $fs->remove($dir);
    }
}

class NoTemplatingEntryKernel extends Kernel
{
    public function registerBundles(): iterable
    {

class NativeFileSessionHandlerTest extends TestCase
{
    public function testConstruct()
    {
        new NativeSessionStorage(['name' => 'TESTING']new NativeFileSessionHandler(sys_get_temp_dir()));

        $this->assertEquals('user', \ini_get('session.save_handler'));

        $this->assertEquals(sys_get_temp_dir(), \ini_get('session.save_path'));
        $this->assertEquals('TESTING', \ini_get('session.name'));
    }

    /** * @dataProvider savePathDataProvider */
    public function testConstructSavePath($savePath$expectedSavePath$path)
    {
--TEST-- Test DeprecationErrorHandler with an ignoreFile --FILE-- <?php $filename = tempnam(sys_get_temp_dir(), 'sf-');
$ignorePatterns = [
  '# A comment line and, below, an empty comment line and an empty line that should be interpreted as a comment.',
  '#',
  '',
  '/^ignored .* deprecation/',
];
file_put_contents($filenameimplode("\n", $ignorePatterns));

$k = 'SYMFONY_DEPRECATIONS_HELPER';
unset($_SERVER[$k]$_ENV[$k]);
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'ignoreFile=' . urlencode($filename));
static::assertInstanceOf(StreamedResponse::class$response);
    }

    /** * @dataProvider provideVersions */
    public function testUpdateChangesComposerJSON(string $shopwareVersion): void
    {
        $recoveryManager = $this->createMock(RecoveryManager::class);

        $fs = new Filesystem();
        $tmpDir = sys_get_temp_dir() . '/' . uniqid('test', true);
        $fs->mkdir($tmpDir);

        $fs->dumpFile($tmpDir . '/composer.json', json_encode([
            'require' => [
                'shopware/core' => '6.1.0',
            ],
        ], \JSON_THROW_ON_ERROR));

        $recoveryManager->method('getShopwareLocation')->willReturn($tmpDir);
        $recoveryManager->method('getCurrentShopwareVersion')->willReturn($shopwareVersion);
        $recoveryManager->method('getBinary')->willReturn('/var/www/shopware-installer.phar.php');
        

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
    {
Home | Imprint | This part of the site doesn't use cookies.