sys_get_temp_dir

Supported Versions: PHP 5 >= 5.2.1, PHP 7, PHP 8
Returns directory path used for temporary files
<?php sys_get_temp_dir(): string
<?php use PHPUnit\Framework\ExpectationFailedException;



test('pass', function () {

    $temp = sys_get_temp_dir();



    expect($temp)->toBeDirectory();

});
<?php use PHPUnit\Framework\ExpectationFailedException;



beforeEach(function () {

    touch($this->tempFile = sys_get_temp_dir().'/fake.file');

});



afterEach(function () {
<?php use PHPUnit\Framework\ExpectationFailedException;



test('pass', function () {

    expect(sys_get_temp_dir())->toBeReadableDirectory();

});



test('failures', function () {
<?php })->throws(ExpectationFailedException::class, 'oh no!');



test('not failures', function () {

    expect(sys_get_temp_dir())->not->toBeReadableDirectory();

})->throws(ExpectationFailedException::class);
<?php use PHPUnit\Framework\ExpectationFailedException;



beforeEach(function () {

    touch($this->tempFile = sys_get_temp_dir().'/fake.file');

});



afterEach(function () {
<?php use PHPUnit\Framework\ExpectationFailedException;



test('pass', function () {

    expect(sys_get_temp_dir())->toBeWritableDirectory();

});



test('failures', function () {
<?php })->throws(ExpectationFailedException::class, 'oh no!');



test('not failures', function () {

    expect(sys_get_temp_dir())->not->toBeWritableDirectory();

})->throws(ExpectationFailedException::class);
<?php use PHPUnit\Framework\ExpectationFailedException;



beforeEach(function () {

    touch($this->tempFile = sys_get_temp_dir().'/fake.file');

});



afterEach(function () {
<?php use Symfony\Component\Process\Process;



$run = function () {

    $junitLogFile = tempnam(sys_get_temp_dir(), 'junit');



    $process = new Process(

        array_merge(['php', 'bin/pest', '--log-junit', $junitLogFile], func_get_args()),