mirror of
https://github.com/friendica/friendica
synced 2025-04-22 21:10:10 +00:00
Just commit config transactions if something changed
This commit is contained in:
parent
aabe39220d
commit
dce86be58e
3 changed files with 34 additions and 8 deletions
|
@ -9,6 +9,7 @@ use Friendica\Core\Config\Util\ConfigFileManager;
|
|||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Mockery\Exception\InvalidCountException;
|
||||
|
||||
class ConfigTransactionTest extends MockedTest
|
||||
{
|
||||
|
@ -108,4 +109,27 @@ class ConfigTransactionTest extends MockedTest
|
|||
// the whole category should be gone
|
||||
self::assertNull($tempData['delete'] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test asserts that in empty transactions, no saveData is called, thus no config file writing was performed
|
||||
*/
|
||||
public function testNothingToDo()
|
||||
{
|
||||
$this->configFileManager = \Mockery::spy(ConfigFileManager::class);
|
||||
|
||||
$config = new Config($this->configFileManager, new Cache());
|
||||
$configTransaction = new ConfigTransaction($config);
|
||||
|
||||
// commit empty transaction
|
||||
$configTransaction->commit();
|
||||
|
||||
try {
|
||||
$this->configFileManager->shouldNotHaveReceived('saveData');
|
||||
} catch (InvalidCountException $exception) {
|
||||
self::fail($exception);
|
||||
}
|
||||
|
||||
// If not failed, the test ends successfully :)
|
||||
self::assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue