1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FilteredTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use ArrayObject; |
7
|
|
|
use CommonTestClass; |
8
|
|
|
use kalanis\kw_input\Filtered; |
9
|
|
|
use kalanis\kw_input\Interfaces; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class ArrayAccessedTest extends CommonTestClass |
13
|
|
|
{ |
14
|
|
|
public function testProcessing(): void |
15
|
|
|
{ |
16
|
|
|
$variables = new Filtered\ArrayAccessed(new ArrayObject([ |
17
|
|
|
'foo' => 'val1', |
18
|
|
|
'bar' => ['bal1', 'bal2'], |
19
|
|
|
'baz' => true, |
20
|
|
|
'aff' => 42, |
21
|
|
|
]), Interfaces\IEntry::SOURCE_CLI); |
22
|
|
|
|
23
|
|
|
/** @var Interfaces\IEntry[] $entries */ |
24
|
|
|
$entries = $variables->getInArray(null, [Interfaces\IEntry::SOURCE_GET]); // sources have no meaning here |
25
|
|
|
$input = new Filtered\FilterAdapter($variables, [Interfaces\IEntry::SOURCE_GET]); |
26
|
|
|
$this->assertNotEmpty(count($entries)); |
27
|
|
|
|
28
|
|
|
$this->assertTrue(isset($input['foo'])); |
29
|
|
|
$this->assertEquals('foo', $input['foo']->getKey()); |
|
|
|
|
30
|
|
|
$this->assertEquals('val1', $input['foo']->getValue()); |
31
|
|
|
$this->assertEquals(Interfaces\IEntry::SOURCE_CLI, $input['foo']->getSource()); |
32
|
|
|
|
33
|
|
|
$this->assertTrue($input->offsetExists('bar')); |
34
|
|
|
$this->assertEquals('bar', $input->offsetGet('bar')->getKey()); |
35
|
|
|
$this->assertEquals(['bal1', 'bal2'], $input->offsetGet('bar')->getValue()); |
36
|
|
|
$this->assertEquals(Interfaces\IEntry::SOURCE_CLI, $input->offsetGet('bar')->getSource()); |
37
|
|
|
|
38
|
|
|
$this->assertTrue(isset($input->baz)); |
|
|
|
|
39
|
|
|
$this->assertEquals('baz', $input->baz->getKey()); |
|
|
|
|
40
|
|
|
$this->assertEquals(true, $input->baz->getValue()); |
41
|
|
|
$this->assertEquals(Interfaces\IEntry::SOURCE_CLI, $input->baz->getSource()); |
42
|
|
|
|
43
|
|
|
$this->assertTrue($input->offsetExists('aff')); |
44
|
|
|
$this->assertEquals('aff', $input->offsetGet('aff')->getKey()); |
45
|
|
|
$this->assertEquals(42, $input->offsetGet('aff')->getValue()); |
46
|
|
|
$this->assertEquals(Interfaces\IEntry::SOURCE_CLI, $input->offsetGet('aff')->getSource()); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.