2014-06-26 09:53:14 -04:00
|
|
|
<?php
|
2026-03-26 12:46:27 -04:00
|
|
|
|
|
|
|
|
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2014-06-26 09:53:14 -04:00
|
|
|
|
|
|
|
|
namespace Tests\Icinga\Util;
|
|
|
|
|
|
|
|
|
|
use Icinga\Util\File;
|
|
|
|
|
use Icinga\Test\BaseTestCase;
|
|
|
|
|
|
|
|
|
|
class FileTest extends BaseTestCase
|
|
|
|
|
{
|
|
|
|
|
public function testWhetherWritingToNonWritableFilesThrowsAnException()
|
|
|
|
|
{
|
2021-04-09 04:49:17 -04:00
|
|
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
|
|
|
|
|
2014-06-26 09:53:14 -04:00
|
|
|
$file = new File('/dev/null');
|
|
|
|
|
$file->fwrite('test');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testWhetherTruncatingNonWritableFilesThrowsAnException()
|
|
|
|
|
{
|
2021-04-09 04:49:17 -04:00
|
|
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
|
|
|
|
|
2014-06-26 09:53:14 -04:00
|
|
|
$file = new File('/dev/null');
|
|
|
|
|
$file->ftruncate(0);
|
|
|
|
|
}
|
|
|
|
|
}
|