forked from ben-xo/dir2cast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for when files are already in the folder.
- Loading branch information
Showing
3 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class AgeDirTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
prepare_testing_dir(); | ||
exec('php dir2cast.php --output=out.xml --dont-uncache --ignore-dir2cast-mtime'); | ||
} | ||
|
||
public function test_age_dir() | ||
{ | ||
$mtime1 = filemtime('dir2cast.php'); | ||
$mtime2 = filemtime('temp'); | ||
$mtime3 = filemtime('.'); | ||
$mtime4 = filemtime('out.xml'); | ||
|
||
age_dir_by('.', 10); | ||
|
||
$this->assertEquals($mtime1 - 10, filemtime('dir2cast.php')); | ||
$this->assertEquals($mtime2 - 10, filemtime('temp')); | ||
$this->assertEquals($mtime3 - 10, filemtime('.')); | ||
$this->assertEquals($mtime4 - 10, filemtime('out.xml')); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
chdir('..'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class CachingTest_prepopulatedTest extends CachingTest | ||
{ | ||
public function setUp(): void | ||
{ | ||
prepare_testing_dir(); | ||
file_put_contents('pre-existing.mp3', 'test'); | ||
touch('pre-existing.mp3', time()-86400); | ||
exec('php dir2cast.php --output=out.xml --dont-uncache --ignore-dir2cast-mtime', $this->output, $this->returncode); | ||
$this->content = file_get_contents($this->file); | ||
clearstatcache(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
$this->assertEquals(1, preg_match('/pre-existing\.mp3/', file_get_contents($this->file))); | ||
parent::tearDown(); | ||
} | ||
} |