[BC] Upgraded dependencies, dropped support for anything below PHP 8.0. (#849)
* GitHub actions + style fixes + updated packages * Fixed workflows dir * Support for PHP 8.1 (#1) * Update README.md * Revert some changes from upstream
This commit is contained in:
parent
72c946dc7d
commit
111c153428
335 changed files with 4394 additions and 28116 deletions
78
tests/Alchemy/BinaryDriver/ConfigurationTest.php
Normal file
78
tests/Alchemy/BinaryDriver/ConfigurationTest.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
public function testArrayAccessImplementation()
|
||||
{
|
||||
$configuration = new Configuration(['key' => 'value']);
|
||||
|
||||
$this->assertTrue(isset($configuration['key']));
|
||||
$this->assertEquals('value', $configuration['key']);
|
||||
|
||||
$this->assertFalse(isset($configuration['key2']));
|
||||
unset($configuration['key']);
|
||||
$this->assertFalse(isset($configuration['key']));
|
||||
|
||||
$configuration['key2'] = 'value2';
|
||||
$this->assertTrue(isset($configuration['key2']));
|
||||
$this->assertEquals('value2', $configuration['key2']);
|
||||
}
|
||||
|
||||
public function testGetOnNonExistentKeyShouldReturnDefaultValue()
|
||||
{
|
||||
$conf = new Configuration();
|
||||
$this->assertEquals('booba', $conf->get('hooba', 'booba'));
|
||||
$this->assertEquals(null, $conf->get('hooba'));
|
||||
}
|
||||
|
||||
public function testSetHasGetRemove()
|
||||
{
|
||||
$configuration = new Configuration(['key' => 'value']);
|
||||
|
||||
$this->assertTrue($configuration->has('key'));
|
||||
$this->assertEquals('value', $configuration->get('key'));
|
||||
|
||||
$this->assertFalse($configuration->has('key2'));
|
||||
$configuration->remove('key');
|
||||
$this->assertFalse($configuration->has('key'));
|
||||
|
||||
$configuration->set('key2', 'value2');
|
||||
$this->assertTrue($configuration->has('key2'));
|
||||
$this->assertEquals('value2', $configuration->get('key2'));
|
||||
}
|
||||
|
||||
public function testIterator()
|
||||
{
|
||||
$data = [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
];
|
||||
|
||||
$captured = [];
|
||||
$conf = new Configuration($data);
|
||||
|
||||
foreach ($conf as $key => $value) {
|
||||
$captured[$key] = $value;
|
||||
}
|
||||
|
||||
$this->assertEquals($data, $captured);
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$data = [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
];
|
||||
|
||||
$conf = new Configuration($data);
|
||||
$this->assertEquals($data, $conf->all());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue