forked from php-soap/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodCollectionTest.php
More file actions
59 lines (47 loc) · 1.75 KB
/
MethodCollectionTest.php
File metadata and controls
59 lines (47 loc) · 1.75 KB
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
54
55
56
57
58
59
<?php
declare(strict_types=1);
namespace SoapTest\Engine\Metadata\Collection;
use PHPUnit\Framework\TestCase;
use Soap\Engine\Exception\MetadataException;
use Soap\Engine\Metadata\Collection\MethodCollection;
use Soap\Engine\Metadata\Collection\ParameterCollection;
use Soap\Engine\Metadata\Model\Method;
use Soap\Engine\Metadata\Model\MethodMeta;
use Soap\Engine\Metadata\Model\XsdType;
final class MethodCollectionTest extends TestCase
{
private MethodCollection $collection;
protected function setUp(): void
{
$this->collection = new MethodCollection(
(new Method('hello', new ParameterCollection(), XsdType::create('Response')))->withMeta(
static fn (MethodMeta $meta) => $meta->withAction('uri:hello')
)
);
}
public function test_it_can_iterate_over_methods(): void
{
static::assertCount(1, $this->collection);
static::assertSame([...$this->collection], $this->collection->map(static fn ($item) => $item));
}
public function test_it_can_fetch_by_name(): void
{
$method = $this->collection->fetchByName('hello');
static::assertSame('hello', $method->getName());
}
public function test_it_can_fail_fetching_by_name(): void
{
$this->expectException(MetadataException::class);
$this->collection->fetchByName('nope');
}
public function test_it_can_fetch_by_soap_action(): void
{
$method = $this->collection->fetchBySoapAction('uri:hello');
static::assertSame('hello', $method->getName());
}
public function test_it_can_fail_fetching_by_soap_action(): void
{
$this->expectException(MetadataException::class);
$this->collection->fetchBySoapAction('uri:nope');
}
}