mirror of
https://github.com/friendica/friendica
synced 2024-12-22 12:40:15 +00:00
Inline KeyValueStorageTest into DBKeyValueStorageTest
This commit is contained in:
parent
54ee36a6aa
commit
f3f52efe18
2 changed files with 77 additions and 92 deletions
|
@ -10,9 +10,10 @@ namespace Friendica\Test\src\Core\KeyValueStorage;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage;
|
use Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
|
use Friendica\Test\MockedTestCase;
|
||||||
use Friendica\Test\Util\CreateDatabaseTrait;
|
use Friendica\Test\Util\CreateDatabaseTrait;
|
||||||
|
|
||||||
class DBKeyValueStorageTest extends KeyValueStorageTest
|
class DBKeyValueStorageTest extends MockedTestCase
|
||||||
{
|
{
|
||||||
use CreateDatabaseTrait;
|
use CreateDatabaseTrait;
|
||||||
|
|
||||||
|
@ -68,4 +69,79 @@ class DBKeyValueStorageTest extends KeyValueStorageTest
|
||||||
|
|
||||||
self::assertGreaterThanOrEqual($updateAt, $updateAtAfter);
|
self::assertGreaterThanOrEqual($updateAt, $updateAtAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInstance()
|
||||||
|
{
|
||||||
|
$instance = $this->getInstance();
|
||||||
|
|
||||||
|
self::assertInstanceOf(IManageKeyValuePairs::class, $instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataTests(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'string' => ['k' => 'data', 'v' => 'it'],
|
||||||
|
'boolTrue' => ['k' => 'data', 'v' => true],
|
||||||
|
'boolFalse' => ['k' => 'data', 'v' => false],
|
||||||
|
'integer' => ['k' => 'data', 'v' => 235],
|
||||||
|
'decimal' => ['k' => 'data', 'v' => 2.456],
|
||||||
|
'array' => ['k' => 'data', 'v' => ['1', 2, '3', true, false]],
|
||||||
|
'boolIntTrue' => ['k' => 'data', 'v' => 1],
|
||||||
|
'boolIntFalse' => ['k' => 'data', 'v' => 0],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataTests
|
||||||
|
*/
|
||||||
|
public function testGetSetDelete($k, $v)
|
||||||
|
{
|
||||||
|
$instance = $this->getInstance();
|
||||||
|
|
||||||
|
$instance->set($k, $v);
|
||||||
|
|
||||||
|
self::assertEquals($v, $instance->get($k));
|
||||||
|
self::assertEquals($v, $instance[$k]);
|
||||||
|
|
||||||
|
$instance->delete($k);
|
||||||
|
|
||||||
|
self::assertNull($instance->get($k));
|
||||||
|
self::assertNull($instance[$k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataTests
|
||||||
|
*/
|
||||||
|
public function testSetOverride($k, $v)
|
||||||
|
{
|
||||||
|
$instance = $this->getInstance();
|
||||||
|
|
||||||
|
$instance->set($k, $v);
|
||||||
|
|
||||||
|
self::assertEquals($v, $instance->get($k));
|
||||||
|
self::assertEquals($v, $instance[$k]);
|
||||||
|
|
||||||
|
$instance->set($k, 'another_value');
|
||||||
|
|
||||||
|
self::assertEquals('another_value', $instance->get($k));
|
||||||
|
self::assertEquals('another_value', $instance[$k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataTests
|
||||||
|
*/
|
||||||
|
public function testOffsetSetDelete($k, $v)
|
||||||
|
{
|
||||||
|
$instance = $this->getInstance();
|
||||||
|
|
||||||
|
$instance[$k] = $v;
|
||||||
|
|
||||||
|
self::assertEquals($v, $instance->get($k));
|
||||||
|
self::assertEquals($v, $instance[$k]);
|
||||||
|
|
||||||
|
unset($instance[$k]);
|
||||||
|
|
||||||
|
self::assertNull($instance->get($k));
|
||||||
|
self::assertNull($instance[$k]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Copyright (C) 2010-2024, the Friendica project
|
|
||||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
|
|
||||||
namespace Friendica\Test\src\Core\KeyValueStorage;
|
|
||||||
|
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
|
||||||
use Friendica\Test\MockedTestCase;
|
|
||||||
|
|
||||||
abstract class KeyValueStorageTest extends MockedTestCase
|
|
||||||
{
|
|
||||||
abstract public function getInstance(): IManageKeyValuePairs;
|
|
||||||
|
|
||||||
public function testInstance()
|
|
||||||
{
|
|
||||||
$instance = $this->getInstance();
|
|
||||||
|
|
||||||
self::assertInstanceOf(IManageKeyValuePairs::class, $instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataTests(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'string' => ['k' => 'data', 'v' => 'it'],
|
|
||||||
'boolTrue' => ['k' => 'data', 'v' => true],
|
|
||||||
'boolFalse' => ['k' => 'data', 'v' => false],
|
|
||||||
'integer' => ['k' => 'data', 'v' => 235],
|
|
||||||
'decimal' => ['k' => 'data', 'v' => 2.456],
|
|
||||||
'array' => ['k' => 'data', 'v' => ['1', 2, '3', true, false]],
|
|
||||||
'boolIntTrue' => ['k' => 'data', 'v' => 1],
|
|
||||||
'boolIntFalse' => ['k' => 'data', 'v' => 0],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider dataTests
|
|
||||||
*/
|
|
||||||
public function testGetSetDelete($k, $v)
|
|
||||||
{
|
|
||||||
$instance = $this->getInstance();
|
|
||||||
|
|
||||||
$instance->set($k, $v);
|
|
||||||
|
|
||||||
self::assertEquals($v, $instance->get($k));
|
|
||||||
self::assertEquals($v, $instance[$k]);
|
|
||||||
|
|
||||||
$instance->delete($k);
|
|
||||||
|
|
||||||
self::assertNull($instance->get($k));
|
|
||||||
self::assertNull($instance[$k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider dataTests
|
|
||||||
*/
|
|
||||||
public function testSetOverride($k, $v)
|
|
||||||
{
|
|
||||||
$instance = $this->getInstance();
|
|
||||||
|
|
||||||
$instance->set($k, $v);
|
|
||||||
|
|
||||||
self::assertEquals($v, $instance->get($k));
|
|
||||||
self::assertEquals($v, $instance[$k]);
|
|
||||||
|
|
||||||
$instance->set($k, 'another_value');
|
|
||||||
|
|
||||||
self::assertEquals('another_value', $instance->get($k));
|
|
||||||
self::assertEquals('another_value', $instance[$k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider dataTests
|
|
||||||
*/
|
|
||||||
public function testOffsetSetDelete($k, $v)
|
|
||||||
{
|
|
||||||
$instance = $this->getInstance();
|
|
||||||
|
|
||||||
$instance[$k] = $v;
|
|
||||||
|
|
||||||
self::assertEquals($v, $instance->get($k));
|
|
||||||
self::assertEquals($v, $instance[$k]);
|
|
||||||
|
|
||||||
unset($instance[$k]);
|
|
||||||
|
|
||||||
self::assertNull($instance->get($k));
|
|
||||||
self::assertNull($instance[$k]);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue