|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PhpWinTools\WmiScripting\Testing\Support; |
|
4
|
|
|
|
|
5
|
|
|
use ArrayIterator; |
|
6
|
|
|
use IteratorAggregate; |
|
7
|
|
|
use PhpWinTools\Support\COM\VariantWrapper; |
|
8
|
|
|
use PhpWinTools\Support\COM\Testing\COMObjectFake; |
|
9
|
|
|
use PhpWinTools\WmiScripting\Testing\CallStacks\ComCallStack; |
|
10
|
|
|
use PhpWinTools\WmiScripting\Support\ApiObjects\SWbemObjectSet; |
|
11
|
|
|
use PhpWinTools\WmiScripting\Support\ApiObjects\SWbemPropertySet; |
|
12
|
|
|
use PhpWinTools\WmiScripting\Support\ApiObjects\SWbemQualifierSet; |
|
13
|
|
|
|
|
14
|
|
|
class VARIANTFake extends COMObjectFake implements IteratorAggregate |
|
15
|
|
|
{ |
|
16
|
|
|
public $value; |
|
17
|
|
|
|
|
18
|
|
|
public $class_name; |
|
19
|
|
|
|
|
20
|
|
|
public $code_page; |
|
21
|
|
|
|
|
22
|
|
|
public $expectations; |
|
23
|
|
|
|
|
24
|
2 |
|
public function __construct($value = null, string $class_name = null, $code_page = null) |
|
25
|
|
|
{ |
|
26
|
2 |
|
parent::__construct(); |
|
27
|
|
|
|
|
28
|
2 |
|
$this->value = $value; |
|
29
|
2 |
|
$this->class_name = $class_name; |
|
30
|
2 |
|
$this->code_page = $code_page; |
|
31
|
2 |
|
} |
|
32
|
|
|
|
|
33
|
2 |
|
public function getIterator() |
|
34
|
|
|
{ |
|
35
|
2 |
|
$this->stack->add('iterator'); |
|
36
|
|
|
|
|
37
|
2 |
|
$standard = new ArrayIterator([ |
|
38
|
2 |
|
new VariantWrapper(new self()), |
|
39
|
|
|
]); |
|
40
|
|
|
|
|
41
|
2 |
|
if (ComCallStack::current()->getCaller()->getClass() === SWbemObjectSet::class) { |
|
42
|
2 |
|
$response = $this->call(__FUNCTION__, '__objectSet__'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
2 |
|
if (ComCallStack::current()->getCaller()->getClass() === SWbemPropertySet::class) { |
|
46
|
2 |
|
$response = $this->call(__FUNCTION__, '__propertySet__'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
2 |
|
if (ComCallStack::current()->getCaller()->getClass() === SWbemQualifierSet::class) { |
|
50
|
2 |
|
$response = $this->call(__FUNCTION__, '__qualifierSet__'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// if (!isset($response)) { |
|
54
|
|
|
// dd(ComCallStack::current()); |
|
55
|
|
|
// } |
|
56
|
|
|
|
|
57
|
2 |
|
return $response ?? $standard; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|