Skip to content

Commit

Permalink
let's see if a warning is triggered by this new test
Browse files Browse the repository at this point in the history
  • Loading branch information
craue committed Mar 8, 2020
1 parent bd2d58c commit a838497
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Tests/Util/TempFileUtilTest.php
@@ -0,0 +1,40 @@
<?php

namespace Craue\FormFlowBundle\Tests\Util;

use Craue\FormFlowBundle\Util\TempFileUtil;
use PHPUnit\Framework\TestCase;

/**
* @group unit
*
* @author Christian Raue <christian.raue@gmail.com>
* @copyright 2011-2020 Christian Raue
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class TempFileUtilTest extends TestCase {

public function testAddAndRemoveFiles() {
$tempFile = tempnam(sys_get_temp_dir(), 'craue_form_flow_temp_file');
$this->assertFileExists($tempFile);

TempFileUtil::addTempFile($tempFile);
$this->assertCount(1, $this->getTempFiles());

// add same file again to ensure that no warning is triggered while trying to remove a non-existing file
TempFileUtil::addTempFile($tempFile);
$this->assertCount(2, $this->getTempFiles());

TempFileUtil::removeTempFiles();
$this->assertCount(0, $this->getTempFiles());
$this->assertFileNotExists($tempFile);
}

private function getTempFiles() {
$reflectionClass = new \ReflectionClass(TempFileUtil::class);
$staticProperties = $reflectionClass->getStaticProperties();

return $staticProperties['tempFiles'];
}

}

0 comments on commit a838497

Please sign in to comment.