mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 09:14:08 +02:00
Rename class DbStoreTest
to PreferencesStoreTest
This commit is contained in:
parent
566f5db8cf
commit
213c60334a
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
namespace Tests\Icinga\User\Preferences\Store;
|
namespace Tests\Icinga\User\Preferences;
|
||||||
|
|
||||||
|
use Icinga\User\Preferences\PreferencesStore;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Exception\NotWritableError;
|
use Icinga\Exception\NotWritableError;
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
use Icinga\User\Preferences\Store\DbStore;
|
|
||||||
|
|
||||||
class DatabaseMock
|
class DatabaseMock
|
||||||
{
|
{
|
||||||
@ -22,19 +22,19 @@ class DatabaseMock
|
|||||||
|
|
||||||
public function insert($table, $row)
|
public function insert($table, $row)
|
||||||
{
|
{
|
||||||
$this->insertions[$row[DbStore::COLUMN_PREFERENCE]] = $row[DbStore::COLUMN_VALUE];
|
$this->insertions[$row[PreferencesStore::COLUMN_PREFERENCE]] = $row[PreferencesStore::COLUMN_VALUE];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($table, $columns, $where)
|
public function update($table, $columns, $where)
|
||||||
{
|
{
|
||||||
$this->updates[$where[DbStore::COLUMN_PREFERENCE . '=?']] = $columns[DbStore::COLUMN_VALUE];
|
$this->updates[$where[PreferencesStore::COLUMN_PREFERENCE . '=?']] = $columns[PreferencesStore::COLUMN_VALUE];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($table, $where)
|
public function delete($table, $where)
|
||||||
{
|
{
|
||||||
$this->deletions = array_merge(
|
$this->deletions = array_merge(
|
||||||
$this->deletions,
|
$this->deletions,
|
||||||
$where[DbStore::COLUMN_PREFERENCE . ' IN (?)']
|
$where[PreferencesStore::COLUMN_PREFERENCE . ' IN (?)']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ class FaultyDatabaseMock extends DatabaseMock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DbStoreWithSetPreferences extends DbStore
|
class PreferencesStoreWithSetPreferences extends PreferencesStore
|
||||||
{
|
{
|
||||||
public function setPreferences(array $preferences)
|
public function setPreferences(array $preferences)
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ class DbStoreWithSetPreferences extends DbStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DbStoreTest extends BaseTestCase
|
class PreferencesStoreTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
public function testWhetherPreferenceInsertionWorks()
|
public function testWhetherPreferenceInsertionWorks()
|
||||||
{
|
{
|
||||||
@ -78,9 +78,9 @@ class DbStoreTest extends BaseTestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertArrayHasKey('key', $dbMock->insertions, 'DbStore::save does not insert new preferences');
|
$this->assertArrayHasKey('key', $dbMock->insertions, 'PreferencesStore::save does not insert new preferences');
|
||||||
$this->assertEmpty($dbMock->updates, 'DbStore::save updates *new* preferences');
|
$this->assertEmpty($dbMock->updates, 'PreferencesStore::save updates *new* preferences');
|
||||||
$this->assertEmpty($dbMock->deletions, 'DbStore::save deletes *new* preferences');
|
$this->assertEmpty($dbMock->deletions, 'PreferencesStore::save deletes *new* preferences');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhetherPreferenceInsertionThrowsNotWritableError()
|
public function testWhetherPreferenceInsertionThrowsNotWritableError()
|
||||||
@ -108,9 +108,9 @@ class DbStoreTest extends BaseTestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertArrayHasKey('key', $dbMock->updates, 'DbStore::save does not update existing preferences');
|
$this->assertArrayHasKey('key', $dbMock->updates, 'PreferencesStore::save does not update existing preferences');
|
||||||
$this->assertEmpty($dbMock->insertions, 'DbStore::save inserts *existing* preferences');
|
$this->assertEmpty($dbMock->insertions, 'PreferencesStore::save inserts *existing* preferences');
|
||||||
$this->assertEmpty($dbMock->deletions, 'DbStore::save inserts *existing* preferneces');
|
$this->assertEmpty($dbMock->deletions, 'PreferencesStore::save inserts *existing* preferneces');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhetherPreferenceUpdatesThrowNotWritableError()
|
public function testWhetherPreferenceUpdatesThrowNotWritableError()
|
||||||
@ -139,9 +139,9 @@ class DbStoreTest extends BaseTestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertContains('key', $dbMock->deletions, 'DbStore::save does not delete removed preferences');
|
$this->assertContains('key', $dbMock->deletions, 'PreferencesStore::save does not delete removed preferences');
|
||||||
$this->assertEmpty($dbMock->insertions, 'DbStore::save inserts *removed* preferences');
|
$this->assertEmpty($dbMock->insertions, 'PreferencesStore::save inserts *removed* preferences');
|
||||||
$this->assertEmpty($dbMock->updates, 'DbStore::save updates *removed* preferences');
|
$this->assertEmpty($dbMock->updates, 'PreferencesStore::save updates *removed* preferences');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhetherPreferenceDeletionThrowsNotWritableError()
|
public function testWhetherPreferenceDeletionThrowsNotWritableError()
|
||||||
@ -160,7 +160,7 @@ class DbStoreTest extends BaseTestCase
|
|||||||
|
|
||||||
protected function getStore($dbMock)
|
protected function getStore($dbMock)
|
||||||
{
|
{
|
||||||
return new DbStoreWithSetPreferences(
|
return new PreferencesStoreWithSetPreferences(
|
||||||
new ConfigObject(
|
new ConfigObject(
|
||||||
array(
|
array(
|
||||||
'connection' => Mockery::mock(array('getDbAdapter' => $dbMock))
|
'connection' => Mockery::mock(array('getDbAdapter' => $dbMock))
|
Loading…
x
Reference in New Issue
Block a user