commit
4bc5350eba
|
@ -17,11 +17,12 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
os: ['ubuntu-latest']
|
||||
include:
|
||||
- php: '5.6'
|
||||
allow_failure: true
|
||||
phplint_options: "--exclude='{(?>.*/)?test/php/.*}' --exclude=library/Icinga/Test/BaseTestCase.php"
|
||||
- php: '7.0'
|
||||
allow_failure: true
|
||||
|
||||
|
@ -40,7 +41,7 @@ jobs:
|
|||
|
||||
- name: PHP Lint
|
||||
if: success() || matrix.allow_failure
|
||||
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} --exclude=library/Icinga/Util/String.php -- .
|
||||
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} --exclude=library/Icinga/Util/String.php ${{ matrix.phplint_options }} -- .
|
||||
|
||||
- name: PHP CodeSniffer
|
||||
if: success() || matrix.allow_failure
|
||||
|
@ -51,14 +52,16 @@ jobs:
|
|||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
phpunit-version: 5.7.27
|
||||
mockery-version: 0.9.9 # *Any* other version is not compatible with PHP 5.6 and anything above phpunit 6
|
||||
phpunit-version: 9.5.4
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||
php: ['7.2', '7.3', '7.4', '8.0']
|
||||
os: ['ubuntu-latest']
|
||||
include:
|
||||
- php: '7.2'
|
||||
phpunit-version: 8.5.15
|
||||
|
||||
services:
|
||||
mysql:
|
||||
|
@ -98,13 +101,13 @@ jobs:
|
|||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: phpunit:${{ env.phpunit-version }}
|
||||
tools: phpunit:${{ matrix.phpunit-version || env.phpunit-version }}
|
||||
extensions: mysql, pgsql, ldap
|
||||
|
||||
- name: Setup dependencies
|
||||
run: |
|
||||
sudo locale-gen en_US.UTF-8 de_DE.UTF-8 fr_FR.UTF-8
|
||||
composer require -n --no-progress mockery/mockery:${{ env.mockery-version }}
|
||||
composer require -n --no-progress mockery/mockery
|
||||
|
||||
- name: PHPUnit
|
||||
env:
|
||||
|
|
|
@ -605,7 +605,7 @@ abstract class ApplicationBootstrap
|
|||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||
if (error_reporting() === 0) {
|
||||
if (! (error_reporting() & $errno)) {
|
||||
// Error was suppressed with the @-operator
|
||||
return false; // Continue with the normal error handler
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Icinga\Test {
|
|||
use Exception;
|
||||
use RuntimeException;
|
||||
use Mockery;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
@ -32,7 +31,7 @@ namespace Icinga\Test {
|
|||
/**
|
||||
* Class BaseTestCase
|
||||
*/
|
||||
abstract class BaseTestCase extends PHPUnit_Framework_TestCase implements DbTest
|
||||
abstract class BaseTestCase extends Mockery\Adapter\Phpunit\MockeryTestCase implements DbTest
|
||||
{
|
||||
/**
|
||||
* Path to application/
|
||||
|
@ -138,7 +137,7 @@ namespace Icinga\Test {
|
|||
/**
|
||||
* Setup MVC bootstrapping and ensure that the Icinga-Mock gets reinitialized
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->setupIcingaMock();
|
||||
|
@ -334,6 +333,23 @@ namespace Icinga\Test {
|
|||
$adapter->exec('DROP TABLE ' . $table . ';');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assertMatchesRegularExpression() method for phpunit >= 8.0 < 9.0 for compatibility with PHP 7.2.
|
||||
*
|
||||
* @TODO Remove once PHP 7.2 support is not needed for testing anymore.
|
||||
*/
|
||||
public static function assertMatchesRegularExpression(
|
||||
string $pattern,
|
||||
string $string,
|
||||
string $message = ''
|
||||
): void {
|
||||
if (method_exists(parent::class, 'assertMatchesRegularExpression')) {
|
||||
parent::assertMatchesRegularExpression($pattern, $string, $message);
|
||||
} else {
|
||||
static::assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BaseTestCase::setupTimezone();
|
||||
|
|
|
@ -96,7 +96,7 @@ class HostdowntimestarthistoryQuery extends IdoQuery
|
|||
array()
|
||||
);
|
||||
|
||||
if (@func_get_arg(0) === false) {
|
||||
if (func_num_args() === 0 || func_get_arg(0) === false) {
|
||||
$this->select->where(
|
||||
"hdh.actual_start_time > '1970-01-02 00:00:00'"
|
||||
);
|
||||
|
|
|
@ -97,7 +97,7 @@ class ServicedowntimestarthistoryQuery extends IdoQuery
|
|||
array()
|
||||
);
|
||||
|
||||
if (@func_get_arg(0) === false) {
|
||||
if (func_num_args() === 0 || func_get_arg(0) === false) {
|
||||
$this->select->where(
|
||||
"sdh.actual_start_time > '1970-01-02 00:00:00'"
|
||||
);
|
||||
|
|
|
@ -20,7 +20,7 @@ class PluginOutputTest extends BaseTestCase
|
|||
|
||||
protected static $statusTags = array('OK', 'WARNING', 'CRITICAL', 'UNKNOWN', 'UP', 'DOWN');
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -45,7 +45,7 @@ class PluginOutputTest extends BaseTestCase
|
|||
$html,
|
||||
preg_quote(self::SUFFIX, '~')
|
||||
);
|
||||
$this->assertRegExp($expect, $actual, 'Output must match example regexp');
|
||||
$this->assertMatchesRegularExpression($expect, $actual, 'Output must match example regexp');
|
||||
} else {
|
||||
$expect = $prefix . $html . self::SUFFIX;
|
||||
$this->assertEquals($expect, $actual, 'Output must match example');
|
||||
|
|
|
@ -8,19 +8,17 @@ use Icinga\Module\Monitoring\Plugin\Perfdata;
|
|||
|
||||
class PerfdataTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWhetherFromStringThrowsExceptionWhenGivenAnEmptyString()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
Perfdata::fromString('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWhetherFromStringThrowsExceptionWhenGivenAnInvalidString()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
Perfdata::fromString('test');
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,10 @@ class MockedRestRequest extends RestRequest
|
|||
|
||||
class RestRequestTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\Json\JsonDecodeException
|
||||
*/
|
||||
public function testInvalidServerResponseHandling()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\Json\JsonDecodeException::class);
|
||||
|
||||
MockedRestRequest::get('http://localhost')->send();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class ConfigWithSetModuleConfig extends Config
|
|||
|
||||
class Bug7043Test extends BaseTestCase
|
||||
{
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Mockery::close(); // Necessary because some tests run in a separate process
|
||||
|
|
|
@ -9,10 +9,10 @@ $currentPos = array_search($wizard->getCurrentPage(), $pages, true);
|
|||
list($configPagesLeft, $configPagesRight) = array_chunk($configPages, count($configPages) / 2, true);
|
||||
|
||||
$visitedPages = array_keys($wizard->getPageData());
|
||||
$maxProgress = @max(array_keys(array_filter(
|
||||
$maxProgress = max(array_merge([0], array_keys(array_filter(
|
||||
$pages,
|
||||
function ($page) use ($visitedPages) { return in_array($page->getName(), $visitedPages); }
|
||||
)));
|
||||
))));
|
||||
|
||||
?>
|
||||
<div id="setup-content-wrapper" data-base-target="layout">
|
||||
|
|
|
@ -12,7 +12,7 @@ require_once BaseTestCase::$appDir . '/views/helpers/DateFormat.php';
|
|||
|
||||
class DateFormatTest extends BaseTestCase
|
||||
{
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
DateTimeFactory::setConfig(array('timezone' => date_default_timezone_get()));
|
||||
}
|
||||
|
|
|
@ -36,10 +36,6 @@ if (file_exists($vendorAutoload)) {
|
|||
|
||||
require_once($icingaLibPath . '/Test/ClassLoader.php');
|
||||
|
||||
if (! class_exists('PHPUnit_Framework_TestCase')) {
|
||||
require_once __DIR__ . '/phpunit-compat.php';
|
||||
}
|
||||
|
||||
$loader = new Icinga\Test\ClassLoader();
|
||||
$loader->registerNamespace('Tests', $testLibraryPath);
|
||||
$loader->registerNamespace('Icinga', $icingaLibPath);
|
||||
|
|
|
@ -26,7 +26,7 @@ class TestStruct
|
|||
|
||||
EOD;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$tempDir = sys_get_temp_dir();
|
||||
|
@ -35,7 +35,7 @@ EOD;
|
|||
file_put_contents($this->baseDir. self::$classFile, self::$classContent);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
system('rm -rf '. $this->baseDir);
|
||||
|
|
|
@ -11,7 +11,7 @@ class ConfigTest extends BaseTestCase
|
|||
/**
|
||||
* Set up config dir
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->oldConfigDir = Config::$configDir;
|
||||
|
@ -21,7 +21,7 @@ class ConfigTest extends BaseTestCase
|
|||
/**
|
||||
* Reset config dir
|
||||
*/
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Config::$configDir = $this->oldConfigDir;
|
||||
|
@ -185,11 +185,10 @@ class ConfigTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException UnexpectedValueException
|
||||
*/
|
||||
public function testWhetherAnExceptionIsThrownWhenTryingToAccessASectionPropertyOnANonSection()
|
||||
{
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
$config = Config::fromArray(array('a' => 'b'));
|
||||
$config->get('a', 'b');
|
||||
}
|
||||
|
@ -234,11 +233,10 @@ class ConfigTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\NotReadableError
|
||||
*/
|
||||
public function testWhetherFromIniThrowsAnExceptionOnInsufficientPermission()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotReadableError::class);
|
||||
|
||||
Config::fromIni('/etc/shadow');
|
||||
}
|
||||
|
||||
|
|
|
@ -32,27 +32,24 @@ class AuditHookTest extends BaseTestCase
|
|||
$this->assertEquals('foo', (new TestAuditHook())->formatMessage('{{te{.}st}}', ['te{' => ['}st' => 'foo']]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFormatMessageComplainsAboutUnresolvedParameters()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
(new TestAuditHook())->formatMessage('{{missing}}', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFormatMessageComplainsAboutNonScalarParameters()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
(new TestAuditHook())->formatMessage('{{test}}', ['test' => ['foo' => 'bar']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFormatMessageComplainsAboutNonArrayParameters()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
(new TestAuditHook())->formatMessage('{{test.foo}}', ['test' => 'foo']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,11 +115,10 @@ class ConfigObjectTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\ProgrammingError
|
||||
*/
|
||||
public function testWhetherItIsNotPossibleToAppendProperties()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||
|
||||
$config = new ConfigObject();
|
||||
$config[] = 'test';
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class ArrayDatasourceTest extends BaseTestCase
|
|||
{
|
||||
private $sampleData;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->sampleData = array(
|
||||
|
|
|
@ -61,7 +61,7 @@ class FilterTest extends BaseTestCase
|
|||
|
||||
private $sampleData;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->sampleData = array(
|
||||
|
|
|
@ -12,13 +12,13 @@ class IniParserTest extends BaseTestCase
|
|||
{
|
||||
protected $tempFile;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->tempFile = tempnam(sys_get_temp_dir(), 'icinga-ini-parser-test');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
unlink($this->tempFile);
|
||||
|
|
|
@ -12,7 +12,7 @@ class IniWriterTest extends BaseTestCase
|
|||
protected $tempFile;
|
||||
protected $tempFile2;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -20,7 +20,7 @@ class IniWriterTest extends BaseTestCase
|
|||
$this->tempFile2 = tempnam(sys_get_temp_dir(), 'icinga-ini-writer-test-2');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
|
@ -275,7 +275,7 @@ inkey' => 'blarg'
|
|||
);
|
||||
|
||||
$rendered = $writer->render();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~linebreak\\\\nin line~',
|
||||
$rendered,
|
||||
'newlines in values are not escaped'
|
||||
|
@ -322,11 +322,10 @@ EOD;
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\ConfigurationError
|
||||
*/
|
||||
public function testWhetherBracketsAreIllegalInSectionNames()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ConfigurationError::class);
|
||||
|
||||
$config = Config::fromArray(['section [brackets]' => []]);
|
||||
(new IniWriter($config, $this->tempFile))->write();
|
||||
}
|
||||
|
@ -419,7 +418,7 @@ EOD;
|
|||
$config->setSection('garbage', $section);
|
||||
|
||||
$iniWriter = new IniWriter($config, '/dev/null');
|
||||
$this->assertNotContains(
|
||||
$this->assertStringNotContainsString(
|
||||
'foobar',
|
||||
$iniWriter->render(),
|
||||
'IniWriter persists section keys with null values'
|
||||
|
@ -434,7 +433,7 @@ EOD;
|
|||
$config->setSection('garbage', $section);
|
||||
|
||||
$iniWriter = new IniWriter($config, '/dev/null');
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'foobar',
|
||||
$iniWriter->render(),
|
||||
'IniWriter doesn\'t persist section keys with empty values'
|
||||
|
@ -451,7 +450,7 @@ EOD;
|
|||
$section = $config->getSection('garbage');
|
||||
$section->foobar = null;
|
||||
$iniWriter = new IniWriter($config, $filename);
|
||||
$this->assertNotContains(
|
||||
$this->assertStringNotContainsString(
|
||||
'foobar',
|
||||
$iniWriter->render(),
|
||||
'IniWriter doesn\'t remove section keys with null values'
|
||||
|
|
|
@ -54,11 +54,10 @@ class LocalFileStorageTest extends BaseTestCase
|
|||
static::assertSame(array('foobar'), array_values(iterator_to_array($lfs->getIterator())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotReadableError
|
||||
*/
|
||||
public function testGetIteratorThrowsNotReadableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotReadableError::class);
|
||||
|
||||
$lfs = new LocalFileStorage('/notreadabledirectory');
|
||||
$lfs->getIterator();
|
||||
}
|
||||
|
@ -79,21 +78,19 @@ class LocalFileStorageTest extends BaseTestCase
|
|||
static::assertSame('Hello world!', $lfs->read('foo/bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\AlreadyExistsException
|
||||
*/
|
||||
public function testCreateThrowsAlreadyExistsException()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\AlreadyExistsException::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->create('foobar', 'Hello world!');
|
||||
$lfs->create('foobar', 'Hello world!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testCreateThrowsNotWritableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$lfs = new LocalFileStorage('/notwritabledirectory');
|
||||
$lfs->create('foobar', 'Hello world!');
|
||||
}
|
||||
|
@ -105,20 +102,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||
static::assertSame('Hello world!', $lfs->read('foobar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotFoundError
|
||||
*/
|
||||
public function testReadThrowsNotFoundError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->read('foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotReadableError
|
||||
*/
|
||||
public function testReadThrowsNotReadableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotReadableError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->create('foobar', 'Hello world!');
|
||||
chmod($lfs->resolvePath('foobar'), 0);
|
||||
|
@ -133,20 +128,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||
static::assertSame('Hello universe!', $lfs->read('foobar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotFoundError
|
||||
*/
|
||||
public function testUpdateThrowsNotFoundError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->update('foobar', 'Hello universe!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testUpdateThrowsNotWritableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->create('foobar', 'Hello world!');
|
||||
chmod($lfs->resolvePath('foobar'), 0);
|
||||
|
@ -161,20 +154,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||
static::assertFalse($lfs->has('foobar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotFoundError
|
||||
*/
|
||||
public function testDeleteThrowsNotFoundError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->delete('foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testDeleteThrowsNotWritableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->create('foobar', 'Hello world!');
|
||||
|
||||
|
@ -204,20 +195,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||
$lfs->resolvePath('./notRelevant/../foobar', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotFoundError
|
||||
*/
|
||||
public function testResolvePathThrowsNotFoundError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||
|
||||
$lfs = new TemporaryLocalFileStorage();
|
||||
$lfs->resolvePath('foobar', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testResolvePathThrowsInvalidArgumentException()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$lfs = new LocalFileStorage('/notreadabledirectory');
|
||||
$lfs->resolvePath('../foobar');
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ use Icinga\Test\BaseTestCase;
|
|||
|
||||
class StreamWriterTest extends BaseTestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->target = tempnam(sys_get_temp_dir(), 'log');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
|
@ -38,6 +38,6 @@ class StreamWriterTest extends BaseTestCase
|
|||
$writer = new FileWriter(new ConfigObject(array('file' => $this->target)));
|
||||
$writer->log(Logger::ERROR, 'This is a test error');
|
||||
$log = file_get_contents($this->target);
|
||||
$this->assertContains('This is a test error', $log, 'StreamWriter does not write log messages');
|
||||
$this->assertStringContainsString('This is a test error', $log, 'StreamWriter does not write log messages');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class BaseTestCaseTest extends BaseTestCase
|
|||
{
|
||||
protected $emptySqlDumpFile;
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
|
@ -148,19 +148,17 @@ class BaseTestCaseTest extends BaseTestCase
|
|||
$this->assertCount(0, $tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testWhetherLoadSqlThrowsErrorWhenFileMissing()
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
$this->loadSql(Mockery::mock('Icinga\Data\Db\DbConnection'), 'not_existing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testWhetherLoadSqlThrowsErrorWhenFileEmpty()
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
$this->emptySqlDumpFile = tempnam(sys_get_temp_dir(), 'icinga2-web-db-test-empty');
|
||||
$this->loadSql(Mockery::mock('Icinga\Data\Db\DbConnection'), $this->emptySqlDumpFile);
|
||||
}
|
||||
|
|
|
@ -83,11 +83,10 @@ class DbStoreTest extends BaseTestCase
|
|||
$this->assertEmpty($dbMock->deletions, 'DbStore::save deletes *new* preferences');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testWhetherPreferenceInsertionThrowsNotWritableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$store = $this->getStore(new FaultyDatabaseMock());
|
||||
$store->save(
|
||||
Mockery::mock(
|
||||
|
@ -114,11 +113,10 @@ class DbStoreTest extends BaseTestCase
|
|||
$this->assertEmpty($dbMock->deletions, 'DbStore::save inserts *existing* preferneces');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testWhetherPreferenceUpdatesThrowNotWritableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$store = $this->getStore(new FaultyDatabaseMock());
|
||||
$store->setPreferences(array('testsection' => array('key' => 'value')));
|
||||
$store->save(
|
||||
|
@ -146,11 +144,10 @@ class DbStoreTest extends BaseTestCase
|
|||
$this->assertEmpty($dbMock->updates, 'DbStore::save updates *removed* preferences');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testWhetherPreferenceDeletionThrowsNotWritableError()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$store = $this->getStore(new FaultyDatabaseMock());
|
||||
$store->setPreferences(array('testsection' => array('key' => 'value')));
|
||||
$store->save(
|
||||
|
|
|
@ -52,11 +52,10 @@ class UserTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWhetherInvalidEmailsCannotBeSet()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$user = new User('unittest');
|
||||
$user->setEmail('mySampleEmail at someDomain dot org');
|
||||
}
|
||||
|
|
|
@ -8,20 +8,18 @@ use Icinga\Test\BaseTestCase;
|
|||
|
||||
class FileTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testWhetherWritingToNonWritableFilesThrowsAnException()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$file = new File('/dev/null');
|
||||
$file->fwrite('test');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\NotWritableError
|
||||
*/
|
||||
public function testWhetherTruncatingNonWritableFilesThrowsAnException()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||
|
||||
$file = new File('/dev/null');
|
||||
$file->ftruncate(0);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class TranslatorWithHardcodedLocaleCodes extends Translator
|
|||
|
||||
class TranslatorTest extends BaseTestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Translator::registerDomain('icingatest', BaseTestCase::$testDir . '/res/locale');
|
||||
|
@ -48,11 +48,10 @@ class TranslatorTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\IcingaException
|
||||
*/
|
||||
public function testWhetherSetupLocaleThrowsAnExceptionWhenGivenAnInvalidLocale()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\IcingaException::class);
|
||||
|
||||
Translator::setupLocale('foobar');
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class SuccessfulForm extends Form
|
|||
|
||||
class FormTest extends BaseTestCase
|
||||
{
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Mockery::close(); // Necessary as some tests are running isolated
|
||||
}
|
||||
|
@ -251,11 +251,10 @@ class FormTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\ProgrammingError
|
||||
*/
|
||||
public function testWhetherTheOnSuccessOptionMustBeCallable()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||
|
||||
new Form(array('onSuccess' => '_invalid_'));
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ class HookTest extends BaseTestCase
|
|||
protected $failingHook = '\\Tests\\Icinga\\Web\\FailingHook';
|
||||
protected $testBaseClass = '\\Icinga\\Web\\Hook\\TestHook';
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
parent::setUp();
|
||||
Hook::clean();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Hook::clean();
|
||||
|
|
|
@ -17,7 +17,7 @@ class SlidingwithborderTest extends BaseTestCase
|
|||
$paginator = new Zend_Paginator($this->getPaginatorAdapter());
|
||||
|
||||
$pages = $scrollingStyle->getPages($paginator);
|
||||
$this->assertInternalType('array', $pages);
|
||||
$this->assertIsArray($pages);
|
||||
$this->assertCount(10, $pages);
|
||||
$this->assertEquals('...', $pages[8]);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class SlidingwithborderTest extends BaseTestCase
|
|||
$paginator->setCurrentPageNumber(9);
|
||||
|
||||
$pages = $scrollingStyle->getPages($paginator);
|
||||
$this->assertInternalType('array', $pages);
|
||||
$this->assertIsArray($pages);
|
||||
$this->assertCount(10, $pages);
|
||||
$this->assertEquals('...', $pages[3]);
|
||||
$this->assertEquals('...', $pages[12]);
|
||||
|
|
|
@ -62,11 +62,10 @@ class SessionNamespaceTest extends BaseTestCase
|
|||
$this->assertNull($ns->get('key2'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\IcingaException
|
||||
*/
|
||||
public function testFailingPropertyAccess()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\IcingaException::class);
|
||||
|
||||
$ns = new SessionNamespace();
|
||||
$ns->missing;
|
||||
}
|
||||
|
|
|
@ -130,11 +130,10 @@ class UrlTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\ProgrammingError
|
||||
*/
|
||||
public function testWhetherFromPathProperlyHandlesInvalidUrls()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||
|
||||
Url::fromPath(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class DashboardWithPredefinableActiveName extends Dashboard
|
|||
|
||||
class DashboardTest extends BaseTestCase
|
||||
{
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Mockery::close(); // Necessary because some tests run in a separate process
|
||||
|
@ -109,11 +109,12 @@ class DashboardTest extends BaseTestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\ProgrammingError
|
||||
* @depends testWhetherCreatePaneCreatesAPane
|
||||
*/
|
||||
public function testWhetherGetPaneThrowsAnExceptionOnNotExistentPaneName()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||
|
||||
$dashboard = new Dashboard();
|
||||
$dashboard->createPane('test1');
|
||||
|
||||
|
@ -267,11 +268,10 @@ class DashboardTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\ConfigurationError
|
||||
*/
|
||||
public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermine()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ConfigurationError::class);
|
||||
|
||||
$dashboard = new Dashboard();
|
||||
$dashboard->determineActivePane();
|
||||
}
|
||||
|
@ -279,11 +279,12 @@ class DashboardTest extends BaseTestCase
|
|||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @expectedException \Icinga\Exception\ProgrammingError
|
||||
* @depends testWhetherCreatePaneCreatesAPane
|
||||
*/
|
||||
public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermineInvalidPane()
|
||||
{
|
||||
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||
|
||||
$dashboard = new DashboardWithPredefinableActiveName();
|
||||
$dashboard->createPane('test1');
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use Icinga\Web\Widget\SearchDashboard;
|
|||
|
||||
class SearchDashboardTest extends BaseTestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$moduleMock = Mockery::mock('Icinga\Application\Modules\Module');
|
||||
$searchUrl = (object) array(
|
||||
|
@ -32,11 +32,10 @@ class SearchDashboardTest extends BaseTestCase
|
|||
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Zend_Controller_Action_Exception
|
||||
*/
|
||||
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()
|
||||
{
|
||||
$this->expectException(\Zend_Controller_Action_Exception::class);
|
||||
|
||||
$user = new User('test');
|
||||
$user->setPermissions(array('*' => '*'));
|
||||
$dashboard = new SearchDashboard();
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
}
|
||||
|
||||
interface PHPUnit_Framework_Test extends \PHPUnit\Framework\Test
|
||||
{
|
||||
}
|
||||
|
||||
interface PHPUnit_Framework_TestListener extends \PHPUnit\Framework\TestListener
|
||||
{
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Tests\Icinga\Regression;
|
||||
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Class Bug4102
|
||||
*
|
||||
* Bogus regression test
|
||||
*
|
||||
* @see https://dev.icinga.com/issues/4102
|
||||
*/
|
||||
class Bug4102Test extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Test class name to match definition
|
||||
*/
|
||||
public function testClassName()
|
||||
{
|
||||
$class = get_class($this);
|
||||
$this->assertContains('Bug4102Test', $class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test namespace to match definition
|
||||
*/
|
||||
public function testNamespace()
|
||||
{
|
||||
$namespace = __NAMESPACE__;
|
||||
$this->assertEquals('Tests\Icinga\Regression', $namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test phpunit inheritance
|
||||
*/
|
||||
public function testInheritance()
|
||||
{
|
||||
$this->assertInstanceOf('\PHPUnit_Framework_TestCase', $this);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue