forked from php-soap/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartialDriverTest.php
More file actions
68 lines (54 loc) · 1.92 KB
/
PartialDriverTest.php
File metadata and controls
68 lines (54 loc) · 1.92 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
60
61
62
63
64
65
66
67
68
<?php
declare(strict_types=1);
namespace SoapTest\Engine;
use PHPUnit\Framework\TestCase;
use Soap\Engine\Decoder;
use Soap\Engine\Encoder;
use Soap\Engine\Exception\DriverException;
use Soap\Engine\HttpBinding\SoapRequest;
use Soap\Engine\HttpBinding\SoapResponse;
use Soap\Engine\PartialDriver;
use SoapTest\Engine\Fixtures\DummyInMemoryMetadata;
final class PartialDriverTest extends TestCase
{
public function test_it_can_encode(): void
{
$encoder = static::createStub(Encoder::class);
$encoder->method('encode')->willReturn(
$request = new SoapRequest('', '', '', SoapRequest::SOAP_1_1)
);
$driver = new PartialDriver(encoder: $encoder);
static::assertEquals($request, $driver->encode('method', []));
}
public function test_it_will_not_encode(): void
{
$this->expectException(DriverException::class);
$driver = new PartialDriver();
$driver->encode('method', []);
}
public function test_it_can_decode(): void
{
$decoder = static::createStub(Decoder::class);
$decoder->method('decode')->willReturn([]);
$driver = new PartialDriver(decoder: $decoder);
static::assertEquals([], $driver->decode('method', new SoapResponse('payload')));
}
public function test_it_will_not_decode(): void
{
$this->expectException(DriverException::class);
$driver = new PartialDriver();
$driver->decode('method', new SoapResponse('payload'));
}
public function test_it_can_provide_metadata(): void
{
$metadata = new DummyInMemoryMetadata();
$driver = new PartialDriver(metadata: $metadata);
static::assertEquals($metadata, $driver->getMetadata());
}
public function test_it_will_not_provide_metadata(): void
{
$this->expectException(DriverException::class);
$driver = new PartialDriver();
$driver->getMetadata();
}
}