1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
<?php
declare(strict_types=1);
namespace Phing\Task\System\Condition;
use Phing\Test\Support\BuildFileTest;
class HasFreeSpaceConditionTest extends BuildFileTest
{
public function setUp(): void
{
$this->configureProject(PHING_TEST_BASE . '/etc/tasks/system/HasFreeSpaceConditionTest.xml');
}
public function testPartitionNotSet()
{
$this->expectBuildExceptionContaining(__FUNCTION__, __FUNCTION__, 'Please set the partition attribute.');
}
public function testNeededNotSet()
{
$this->expectBuildExceptionContaining(__FUNCTION__, __FUNCTION__, 'Please set the needed attribute.');
}
public function testInvalidPartition()
{
$warning = '';
set_error_handler(static function (int $errno, string $errstr) use (&$warning): void {
$warning = $errstr;
}, E_WARNING);
$this->expectBuildExceptionContaining(__FUNCTION__, __FUNCTION__, 'Error while retrieving free space.');
$this->assertSame('disk_free_space(): No such file or directory', $warning);
restore_error_handler();
}
public function testEnoughSpace()
{
$this->executeTarget(__FUNCTION__);
$this->assertInLogs('HasFreeSpaceConditionTest: Enough space in disk.');
}
/**
* @group 32bit-incompatible
*/
#[\PHPUnit\Framework\Attributes\Group('32bit-incompatible')]
public function testNotEnoughSpace()
{
$this->executeTarget(__FUNCTION__);
$this->assertInLogs('HasFreeSpaceConditionTest: Not enough space in disk.');
}
}
|