Skip to content

Commit 3efee7d

Browse files
Improved 'CollectorTest' with compression testing
1 parent c3214bd commit 3efee7d

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

tests/_files/collector/static-dir-compressed/bar-33.txt.zip

Whitespace-only changes.

tests/_files/collector/static-dir-compressed/foo-07.txt.zip

Whitespace-only changes.

tests/_files/collector/static-dir-compressed/foo-11.txt.zip

Whitespace-only changes.

tests/_files/collector/static-dir-compressed/foo-17.txt.zip

Whitespace-only changes.

tests/_files/collector/static-dir-compressed/foo-23.txt.zip

Whitespace-only changes.

tests/phpbu/Backup/CollectorTest.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ public function testMatchFiles()
2929
$this->assertEquals(4, count($files), '4 files should be found');
3030
}
3131

32+
/**
33+
* Test the Backup collector with no dynamic directory
34+
* Files not matching foo-%d.txt.zip should be ignored.
35+
*/
36+
public function testMatchFilesCompressed()
37+
{
38+
$path = $this->getTestDataDir() . '/collector/static-dir-compressed';
39+
$filename = 'foo-%d.txt';
40+
$target = new Target($path, $filename, strtotime('2014-12-01 04:30:57'));
41+
$target->setCompressor($this->getCompressorMockForCmd('zip', 'zip'));
42+
$collector = new Collector($target);
43+
$files = $collector->getBackupFiles();
44+
45+
$this->assertEquals(4, count($files), '4 files should be found');
46+
}
47+
3248
/**
3349
* Test the Backup collector with one dynamic directory
3450
*/
@@ -86,7 +102,25 @@ public function testMultipleDynamicDirectoriesSkipCurrent()
86102
}
87103

88104
/**
89-
* Return testdata directory
105+
* Create Compressor Mock.
106+
*
107+
* @param string $cmd
108+
* @param string $suffix
109+
* @return \phpbu\Backup\Compressor
110+
*/
111+
protected function getCompressorMockForCmd($cmd, $suffix)
112+
{
113+
$compressorStub = $this->getMockBuilder('\\phpbu\\Backup\\Compressor')
114+
->disableOriginalConstructor()
115+
->getMock();
116+
$compressorStub->method('getCommand')->willReturn($cmd);
117+
$compressorStub->method('getSuffix')->willReturn($suffix);
118+
119+
return $compressorStub;
120+
}
121+
122+
/**
123+
* Return test data directory
90124
*
91125
* @return string
92126
*/

0 commit comments

Comments
 (0)