mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 22:34:24 +02:00
tests: Don't make use of deprecated phpunit features
This commit is contained in:
parent
bc1c967dec
commit
f27e872d90
@ -8,19 +8,17 @@ use Icinga\Module\Monitoring\Plugin\Perfdata;
|
|||||||
|
|
||||||
class PerfdataTest extends BaseTestCase
|
class PerfdataTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testWhetherFromStringThrowsExceptionWhenGivenAnEmptyString()
|
public function testWhetherFromStringThrowsExceptionWhenGivenAnEmptyString()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
Perfdata::fromString('');
|
Perfdata::fromString('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testWhetherFromStringThrowsExceptionWhenGivenAnInvalidString()
|
public function testWhetherFromStringThrowsExceptionWhenGivenAnInvalidString()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
Perfdata::fromString('test');
|
Perfdata::fromString('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,10 @@ class MockedRestRequest extends RestRequest
|
|||||||
|
|
||||||
class RestRequestTest extends BaseTestCase
|
class RestRequestTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\Json\JsonDecodeException
|
|
||||||
*/
|
|
||||||
public function testInvalidServerResponseHandling()
|
public function testInvalidServerResponseHandling()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\Json\JsonDecodeException::class);
|
||||||
|
|
||||||
MockedRestRequest::get('http://localhost')->send();
|
MockedRestRequest::get('http://localhost')->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,11 +185,10 @@ class ConfigTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException UnexpectedValueException
|
|
||||||
*/
|
|
||||||
public function testWhetherAnExceptionIsThrownWhenTryingToAccessASectionPropertyOnANonSection()
|
public function testWhetherAnExceptionIsThrownWhenTryingToAccessASectionPropertyOnANonSection()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\UnexpectedValueException::class);
|
||||||
|
|
||||||
$config = Config::fromArray(array('a' => 'b'));
|
$config = Config::fromArray(array('a' => 'b'));
|
||||||
$config->get('a', 'b');
|
$config->get('a', 'b');
|
||||||
}
|
}
|
||||||
@ -234,11 +233,10 @@ class ConfigTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Icinga\Exception\NotReadableError
|
|
||||||
*/
|
|
||||||
public function testWhetherFromIniThrowsAnExceptionOnInsufficientPermission()
|
public function testWhetherFromIniThrowsAnExceptionOnInsufficientPermission()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotReadableError::class);
|
||||||
|
|
||||||
Config::fromIni('/etc/shadow');
|
Config::fromIni('/etc/shadow');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,27 +32,24 @@ class AuditHookTest extends BaseTestCase
|
|||||||
$this->assertEquals('foo', (new TestAuditHook())->formatMessage('{{te{.}st}}', ['te{' => ['}st' => 'foo']]));
|
$this->assertEquals('foo', (new TestAuditHook())->formatMessage('{{te{.}st}}', ['te{' => ['}st' => 'foo']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testFormatMessageComplainsAboutUnresolvedParameters()
|
public function testFormatMessageComplainsAboutUnresolvedParameters()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
(new TestAuditHook())->formatMessage('{{missing}}', []);
|
(new TestAuditHook())->formatMessage('{{missing}}', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testFormatMessageComplainsAboutNonScalarParameters()
|
public function testFormatMessageComplainsAboutNonScalarParameters()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
(new TestAuditHook())->formatMessage('{{test}}', ['test' => ['foo' => 'bar']]);
|
(new TestAuditHook())->formatMessage('{{test}}', ['test' => ['foo' => 'bar']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testFormatMessageComplainsAboutNonArrayParameters()
|
public function testFormatMessageComplainsAboutNonArrayParameters()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
(new TestAuditHook())->formatMessage('{{test.foo}}', ['test' => 'foo']);
|
(new TestAuditHook())->formatMessage('{{test.foo}}', ['test' => 'foo']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,11 +115,10 @@ class ConfigObjectTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\ProgrammingError
|
|
||||||
*/
|
|
||||||
public function testWhetherItIsNotPossibleToAppendProperties()
|
public function testWhetherItIsNotPossibleToAppendProperties()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||||
|
|
||||||
$config = new ConfigObject();
|
$config = new ConfigObject();
|
||||||
$config[] = 'test';
|
$config[] = 'test';
|
||||||
}
|
}
|
||||||
|
@ -322,11 +322,10 @@ EOD;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\ConfigurationError
|
|
||||||
*/
|
|
||||||
public function testWhetherBracketsAreIllegalInSectionNames()
|
public function testWhetherBracketsAreIllegalInSectionNames()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ConfigurationError::class);
|
||||||
|
|
||||||
$config = Config::fromArray(['section [brackets]' => []]);
|
$config = Config::fromArray(['section [brackets]' => []]);
|
||||||
(new IniWriter($config, $this->tempFile))->write();
|
(new IniWriter($config, $this->tempFile))->write();
|
||||||
}
|
}
|
||||||
@ -419,7 +418,7 @@ EOD;
|
|||||||
$config->setSection('garbage', $section);
|
$config->setSection('garbage', $section);
|
||||||
|
|
||||||
$iniWriter = new IniWriter($config, '/dev/null');
|
$iniWriter = new IniWriter($config, '/dev/null');
|
||||||
$this->assertNotContains(
|
$this->assertStringNotContainsString(
|
||||||
'foobar',
|
'foobar',
|
||||||
$iniWriter->render(),
|
$iniWriter->render(),
|
||||||
'IniWriter persists section keys with null values'
|
'IniWriter persists section keys with null values'
|
||||||
@ -434,7 +433,7 @@ EOD;
|
|||||||
$config->setSection('garbage', $section);
|
$config->setSection('garbage', $section);
|
||||||
|
|
||||||
$iniWriter = new IniWriter($config, '/dev/null');
|
$iniWriter = new IniWriter($config, '/dev/null');
|
||||||
$this->assertContains(
|
$this->assertStringContainsString(
|
||||||
'foobar',
|
'foobar',
|
||||||
$iniWriter->render(),
|
$iniWriter->render(),
|
||||||
'IniWriter doesn\'t persist section keys with empty values'
|
'IniWriter doesn\'t persist section keys with empty values'
|
||||||
@ -451,7 +450,7 @@ EOD;
|
|||||||
$section = $config->getSection('garbage');
|
$section = $config->getSection('garbage');
|
||||||
$section->foobar = null;
|
$section->foobar = null;
|
||||||
$iniWriter = new IniWriter($config, $filename);
|
$iniWriter = new IniWriter($config, $filename);
|
||||||
$this->assertNotContains(
|
$this->assertStringNotContainsString(
|
||||||
'foobar',
|
'foobar',
|
||||||
$iniWriter->render(),
|
$iniWriter->render(),
|
||||||
'IniWriter doesn\'t remove section keys with null values'
|
'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())));
|
static::assertSame(array('foobar'), array_values(iterator_to_array($lfs->getIterator())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotReadableError
|
|
||||||
*/
|
|
||||||
public function testGetIteratorThrowsNotReadableError()
|
public function testGetIteratorThrowsNotReadableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotReadableError::class);
|
||||||
|
|
||||||
$lfs = new LocalFileStorage('/notreadabledirectory');
|
$lfs = new LocalFileStorage('/notreadabledirectory');
|
||||||
$lfs->getIterator();
|
$lfs->getIterator();
|
||||||
}
|
}
|
||||||
@ -79,21 +78,19 @@ class LocalFileStorageTest extends BaseTestCase
|
|||||||
static::assertSame('Hello world!', $lfs->read('foo/bar'));
|
static::assertSame('Hello world!', $lfs->read('foo/bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\AlreadyExistsException
|
|
||||||
*/
|
|
||||||
public function testCreateThrowsAlreadyExistsException()
|
public function testCreateThrowsAlreadyExistsException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\AlreadyExistsException::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->create('foobar', 'Hello world!');
|
$lfs->create('foobar', 'Hello world!');
|
||||||
$lfs->create('foobar', 'Hello world!');
|
$lfs->create('foobar', 'Hello world!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testCreateThrowsNotWritableError()
|
public function testCreateThrowsNotWritableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$lfs = new LocalFileStorage('/notwritabledirectory');
|
$lfs = new LocalFileStorage('/notwritabledirectory');
|
||||||
$lfs->create('foobar', 'Hello world!');
|
$lfs->create('foobar', 'Hello world!');
|
||||||
}
|
}
|
||||||
@ -105,20 +102,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||||||
static::assertSame('Hello world!', $lfs->read('foobar'));
|
static::assertSame('Hello world!', $lfs->read('foobar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotFoundError
|
|
||||||
*/
|
|
||||||
public function testReadThrowsNotFoundError()
|
public function testReadThrowsNotFoundError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->read('foobar');
|
$lfs->read('foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotReadableError
|
|
||||||
*/
|
|
||||||
public function testReadThrowsNotReadableError()
|
public function testReadThrowsNotReadableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotReadableError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->create('foobar', 'Hello world!');
|
$lfs->create('foobar', 'Hello world!');
|
||||||
chmod($lfs->resolvePath('foobar'), 0);
|
chmod($lfs->resolvePath('foobar'), 0);
|
||||||
@ -133,20 +128,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||||||
static::assertSame('Hello universe!', $lfs->read('foobar'));
|
static::assertSame('Hello universe!', $lfs->read('foobar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotFoundError
|
|
||||||
*/
|
|
||||||
public function testUpdateThrowsNotFoundError()
|
public function testUpdateThrowsNotFoundError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->update('foobar', 'Hello universe!');
|
$lfs->update('foobar', 'Hello universe!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testUpdateThrowsNotWritableError()
|
public function testUpdateThrowsNotWritableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->create('foobar', 'Hello world!');
|
$lfs->create('foobar', 'Hello world!');
|
||||||
chmod($lfs->resolvePath('foobar'), 0);
|
chmod($lfs->resolvePath('foobar'), 0);
|
||||||
@ -161,20 +154,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||||||
static::assertFalse($lfs->has('foobar'));
|
static::assertFalse($lfs->has('foobar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotFoundError
|
|
||||||
*/
|
|
||||||
public function testDeleteThrowsNotFoundError()
|
public function testDeleteThrowsNotFoundError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->delete('foobar');
|
$lfs->delete('foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testDeleteThrowsNotWritableError()
|
public function testDeleteThrowsNotWritableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->create('foobar', 'Hello world!');
|
$lfs->create('foobar', 'Hello world!');
|
||||||
|
|
||||||
@ -204,20 +195,18 @@ class LocalFileStorageTest extends BaseTestCase
|
|||||||
$lfs->resolvePath('./notRelevant/../foobar', true);
|
$lfs->resolvePath('./notRelevant/../foobar', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotFoundError
|
|
||||||
*/
|
|
||||||
public function testResolvePathThrowsNotFoundError()
|
public function testResolvePathThrowsNotFoundError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotFoundError::class);
|
||||||
|
|
||||||
$lfs = new TemporaryLocalFileStorage();
|
$lfs = new TemporaryLocalFileStorage();
|
||||||
$lfs->resolvePath('foobar', true);
|
$lfs->resolvePath('foobar', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testResolvePathThrowsInvalidArgumentException()
|
public function testResolvePathThrowsInvalidArgumentException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
$lfs = new LocalFileStorage('/notreadabledirectory');
|
$lfs = new LocalFileStorage('/notreadabledirectory');
|
||||||
$lfs->resolvePath('../foobar');
|
$lfs->resolvePath('../foobar');
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,6 @@ class StreamWriterTest extends BaseTestCase
|
|||||||
$writer = new FileWriter(new ConfigObject(array('file' => $this->target)));
|
$writer = new FileWriter(new ConfigObject(array('file' => $this->target)));
|
||||||
$writer->log(Logger::ERROR, 'This is a test error');
|
$writer->log(Logger::ERROR, 'This is a test error');
|
||||||
$log = file_get_contents($this->target);
|
$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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,19 +148,17 @@ class BaseTestCaseTest extends BaseTestCase
|
|||||||
$this->assertCount(0, $tables);
|
$this->assertCount(0, $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException RuntimeException
|
|
||||||
*/
|
|
||||||
public function testWhetherLoadSqlThrowsErrorWhenFileMissing()
|
public function testWhetherLoadSqlThrowsErrorWhenFileMissing()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\RuntimeException::class);
|
||||||
|
|
||||||
$this->loadSql(Mockery::mock('Icinga\Data\Db\DbConnection'), 'not_existing');
|
$this->loadSql(Mockery::mock('Icinga\Data\Db\DbConnection'), 'not_existing');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException RuntimeException
|
|
||||||
*/
|
|
||||||
public function testWhetherLoadSqlThrowsErrorWhenFileEmpty()
|
public function testWhetherLoadSqlThrowsErrorWhenFileEmpty()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\RuntimeException::class);
|
||||||
|
|
||||||
$this->emptySqlDumpFile = tempnam(sys_get_temp_dir(), 'icinga2-web-db-test-empty');
|
$this->emptySqlDumpFile = tempnam(sys_get_temp_dir(), 'icinga2-web-db-test-empty');
|
||||||
$this->loadSql(Mockery::mock('Icinga\Data\Db\DbConnection'), $this->emptySqlDumpFile);
|
$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');
|
$this->assertEmpty($dbMock->deletions, 'DbStore::save deletes *new* preferences');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testWhetherPreferenceInsertionThrowsNotWritableError()
|
public function testWhetherPreferenceInsertionThrowsNotWritableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$store = $this->getStore(new FaultyDatabaseMock());
|
$store = $this->getStore(new FaultyDatabaseMock());
|
||||||
$store->save(
|
$store->save(
|
||||||
Mockery::mock(
|
Mockery::mock(
|
||||||
@ -114,11 +113,10 @@ class DbStoreTest extends BaseTestCase
|
|||||||
$this->assertEmpty($dbMock->deletions, 'DbStore::save inserts *existing* preferneces');
|
$this->assertEmpty($dbMock->deletions, 'DbStore::save inserts *existing* preferneces');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testWhetherPreferenceUpdatesThrowNotWritableError()
|
public function testWhetherPreferenceUpdatesThrowNotWritableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$store = $this->getStore(new FaultyDatabaseMock());
|
$store = $this->getStore(new FaultyDatabaseMock());
|
||||||
$store->setPreferences(array('testsection' => array('key' => 'value')));
|
$store->setPreferences(array('testsection' => array('key' => 'value')));
|
||||||
$store->save(
|
$store->save(
|
||||||
@ -146,11 +144,10 @@ class DbStoreTest extends BaseTestCase
|
|||||||
$this->assertEmpty($dbMock->updates, 'DbStore::save updates *removed* preferences');
|
$this->assertEmpty($dbMock->updates, 'DbStore::save updates *removed* preferences');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testWhetherPreferenceDeletionThrowsNotWritableError()
|
public function testWhetherPreferenceDeletionThrowsNotWritableError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$store = $this->getStore(new FaultyDatabaseMock());
|
$store = $this->getStore(new FaultyDatabaseMock());
|
||||||
$store->setPreferences(array('testsection' => array('key' => 'value')));
|
$store->setPreferences(array('testsection' => array('key' => 'value')));
|
||||||
$store->save(
|
$store->save(
|
||||||
|
@ -52,11 +52,10 @@ class UserTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testWhetherInvalidEmailsCannotBeSet()
|
public function testWhetherInvalidEmailsCannotBeSet()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|
||||||
$user = new User('unittest');
|
$user = new User('unittest');
|
||||||
$user->setEmail('mySampleEmail at someDomain dot org');
|
$user->setEmail('mySampleEmail at someDomain dot org');
|
||||||
}
|
}
|
||||||
|
@ -8,20 +8,18 @@ use Icinga\Test\BaseTestCase;
|
|||||||
|
|
||||||
class FileTest extends BaseTestCase
|
class FileTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testWhetherWritingToNonWritableFilesThrowsAnException()
|
public function testWhetherWritingToNonWritableFilesThrowsAnException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$file = new File('/dev/null');
|
$file = new File('/dev/null');
|
||||||
$file->fwrite('test');
|
$file->fwrite('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\NotWritableError
|
|
||||||
*/
|
|
||||||
public function testWhetherTruncatingNonWritableFilesThrowsAnException()
|
public function testWhetherTruncatingNonWritableFilesThrowsAnException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\NotWritableError::class);
|
||||||
|
|
||||||
$file = new File('/dev/null');
|
$file = new File('/dev/null');
|
||||||
$file->ftruncate(0);
|
$file->ftruncate(0);
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,10 @@ class TranslatorTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Icinga\Exception\IcingaException
|
|
||||||
*/
|
|
||||||
public function testWhetherSetupLocaleThrowsAnExceptionWhenGivenAnInvalidLocale()
|
public function testWhetherSetupLocaleThrowsAnExceptionWhenGivenAnInvalidLocale()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\IcingaException::class);
|
||||||
|
|
||||||
Translator::setupLocale('foobar');
|
Translator::setupLocale('foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,11 +251,10 @@ class FormTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\ProgrammingError
|
|
||||||
*/
|
|
||||||
public function testWhetherTheOnSuccessOptionMustBeCallable()
|
public function testWhetherTheOnSuccessOptionMustBeCallable()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||||
|
|
||||||
new Form(array('onSuccess' => '_invalid_'));
|
new Form(array('onSuccess' => '_invalid_'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class SlidingwithborderTest extends BaseTestCase
|
|||||||
$paginator = new Zend_Paginator($this->getPaginatorAdapter());
|
$paginator = new Zend_Paginator($this->getPaginatorAdapter());
|
||||||
|
|
||||||
$pages = $scrollingStyle->getPages($paginator);
|
$pages = $scrollingStyle->getPages($paginator);
|
||||||
$this->assertInternalType('array', $pages);
|
$this->assertIsArray($pages);
|
||||||
$this->assertCount(10, $pages);
|
$this->assertCount(10, $pages);
|
||||||
$this->assertEquals('...', $pages[8]);
|
$this->assertEquals('...', $pages[8]);
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ class SlidingwithborderTest extends BaseTestCase
|
|||||||
$paginator->setCurrentPageNumber(9);
|
$paginator->setCurrentPageNumber(9);
|
||||||
|
|
||||||
$pages = $scrollingStyle->getPages($paginator);
|
$pages = $scrollingStyle->getPages($paginator);
|
||||||
$this->assertInternalType('array', $pages);
|
$this->assertIsArray($pages);
|
||||||
$this->assertCount(10, $pages);
|
$this->assertCount(10, $pages);
|
||||||
$this->assertEquals('...', $pages[3]);
|
$this->assertEquals('...', $pages[3]);
|
||||||
$this->assertEquals('...', $pages[12]);
|
$this->assertEquals('...', $pages[12]);
|
||||||
|
@ -62,11 +62,10 @@ class SessionNamespaceTest extends BaseTestCase
|
|||||||
$this->assertNull($ns->get('key2'));
|
$this->assertNull($ns->get('key2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Icinga\Exception\IcingaException
|
|
||||||
*/
|
|
||||||
public function testFailingPropertyAccess()
|
public function testFailingPropertyAccess()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\IcingaException::class);
|
||||||
|
|
||||||
$ns = new SessionNamespace();
|
$ns = new SessionNamespace();
|
||||||
$ns->missing;
|
$ns->missing;
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,10 @@ class UrlTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Icinga\Exception\ProgrammingError
|
|
||||||
*/
|
|
||||||
public function testWhetherFromPathProperlyHandlesInvalidUrls()
|
public function testWhetherFromPathProperlyHandlesInvalidUrls()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||||
|
|
||||||
Url::fromPath(null);
|
Url::fromPath(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,11 +109,12 @@ class DashboardTest extends BaseTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Icinga\Exception\ProgrammingError
|
|
||||||
* @depends testWhetherCreatePaneCreatesAPane
|
* @depends testWhetherCreatePaneCreatesAPane
|
||||||
*/
|
*/
|
||||||
public function testWhetherGetPaneThrowsAnExceptionOnNotExistentPaneName()
|
public function testWhetherGetPaneThrowsAnExceptionOnNotExistentPaneName()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||||
|
|
||||||
$dashboard = new Dashboard();
|
$dashboard = new Dashboard();
|
||||||
$dashboard->createPane('test1');
|
$dashboard->createPane('test1');
|
||||||
|
|
||||||
@ -267,11 +268,10 @@ class DashboardTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icinga\Exception\ConfigurationError
|
|
||||||
*/
|
|
||||||
public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermine()
|
public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermine()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ConfigurationError::class);
|
||||||
|
|
||||||
$dashboard = new Dashboard();
|
$dashboard = new Dashboard();
|
||||||
$dashboard->determineActivePane();
|
$dashboard->determineActivePane();
|
||||||
}
|
}
|
||||||
@ -279,11 +279,12 @@ class DashboardTest extends BaseTestCase
|
|||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @expectedException \Icinga\Exception\ProgrammingError
|
|
||||||
* @depends testWhetherCreatePaneCreatesAPane
|
* @depends testWhetherCreatePaneCreatesAPane
|
||||||
*/
|
*/
|
||||||
public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermineInvalidPane()
|
public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermineInvalidPane()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Icinga\Exception\ProgrammingError::class);
|
||||||
|
|
||||||
$dashboard = new DashboardWithPredefinableActiveName();
|
$dashboard = new DashboardWithPredefinableActiveName();
|
||||||
$dashboard->createPane('test1');
|
$dashboard->createPane('test1');
|
||||||
|
|
||||||
|
@ -32,11 +32,10 @@ class SearchDashboardTest extends BaseTestCase
|
|||||||
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
|
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Zend_Controller_Action_Exception
|
|
||||||
*/
|
|
||||||
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()
|
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Zend_Controller_Action_Exception::class);
|
||||||
|
|
||||||
$user = new User('test');
|
$user = new User('test');
|
||||||
$user->setPermissions(array('*' => '*'));
|
$user->setPermissions(array('*' => '*'));
|
||||||
$dashboard = new SearchDashboard();
|
$dashboard = new SearchDashboard();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user