/
Insensitive.php
53 lines (48 loc) · 1.67 KB
/
Insensitive.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/main/blob/master/LICENSE
*/
namespace Quid\Test\Main;
use Quid\Base;
use Quid\Main;
// insensitive
// class for testing Quid\Main\Insensitive
class Insensitive extends Base\Test
{
// trigger
final public static function trigger(array $data):bool
{
// construct
$ins = new Main\Insensitive(['test'=>'James','ok'=>2]);
$vins = new Main\Insensitive(['test','TEST','OK']);
$ins2 = new Main\Insensitive();
// map
$ins2['TEST'] = 'OK';
assert($ins2['test'] === 'OK');
unset($ins2['tEST']);
$ins2['tést'] = 'OKé';
assert($ins2['TÉST'] === 'OKé');
assert($ins->append(['test'=>'meh'],['TEST'=>'LOL'])->toArray() === ['ok'=>2,'TEST'=>'LOL']);
assert($ins->prepend(22,33,'testz')[0] === 22);
assert($ins->append(22,33,'testz')[5] === 'testz');
assert($ins->remove(22,33,'testz') === $ins);
assert($ins->count() === 2);
assert($ins->exists('test'));
assert($ins->exists('TEST'));
assert($ins2->in('OKÉ'));
assert($ins2->search('OKÉ') === 'tést');
assert($vins->count() === 3);
assert($vins->keys('test') === [0,1]);
assert($ins2->gets('TÉST') === ['TÉST'=>'OKé']);
assert($ins2->slice('TÉST',true) === ['tést'=>'OKé']);
assert($ins->set('TeSt',2)->count(2));
assert($ins->get('test') === 2);
assert($ins->unset('TeST')->count() === 1);
$ins2['ok'] = 2;
return true;
}
}
?>