5
5
namespace Osteel \OpenApi \Testing \Tests ;
6
6
7
7
use InvalidArgumentException ;
8
- use Osteel \OpenApi \Testing \Adapters \AdapterInterface ;
8
+ use Osteel \OpenApi \Testing \Adapters \MessageAdapterInterface ;
9
+ use Osteel \OpenApi \Testing \Cache \CacheAdapterInterface ;
9
10
use Osteel \OpenApi \Testing \Validator ;
10
11
use Osteel \OpenApi \Testing \ValidatorBuilder ;
12
+ use stdClass ;
11
13
12
14
class ValidatorBuilderTest extends TestCase
13
15
{
@@ -28,7 +30,7 @@ public static function definitionProvider(): array
28
30
/**
29
31
* @dataProvider definitionProvider
30
32
*/
31
- public function testItBuildsAValidator (string $ method , string $ definition )
33
+ public function testItBuildsAValidator (string $ method , string $ definition ): void
32
34
{
33
35
$ result = ValidatorBuilder::$ method ($ definition )->getValidator ();
34
36
@@ -42,24 +44,44 @@ public function testItBuildsAValidator(string $method, string $definition)
42
44
$ this ->assertTrue ($ result ->get ($ response , static ::PATH ));
43
45
}
44
46
45
- public function testItDoesNotSetTheAdapterBecauseItsTypeIsInvalid ()
47
+ public function testItDoesNotSetTheAdapterBecauseItsTypeIsInvalid (): void
46
48
{
47
49
$ this ->expectException (InvalidArgumentException::class);
48
50
$ this ->expectExceptionMessage (sprintf (
49
51
'Class %s does not implement the %s interface ' ,
50
- InvalidArgumentException ::class,
51
- AdapterInterface ::class
52
+ stdClass ::class,
53
+ MessageAdapterInterface ::class
52
54
));
53
55
54
- ValidatorBuilder::fromYaml (self ::$ yamlDefinition )->setAdapter (InvalidArgumentException ::class);
56
+ ValidatorBuilder::fromYaml (self ::$ yamlDefinition )->setMessageAdapter (stdClass ::class);
55
57
}
56
58
57
- public function testItSetsTheAdapter ()
59
+ public function testItSetsTheAdapter (): void
58
60
{
59
61
ValidatorBuilder::fromYaml (self ::$ yamlDefinition )
60
- ->setAdapter ( get_class ( $ this ->createMock (AdapterInterface ::class)) );
62
+ ->setMessageAdapter ( $ this ->createMock (MessageAdapterInterface ::class)::class );
61
63
62
64
// No exception means the test was successful.
63
65
$ this ->assertTrue (true );
64
66
}
67
+
68
+ public function testItDoesNotSetTheCacheAdapterBecauseItsTypeIsInvalid (): void
69
+ {
70
+ $ this ->expectException (InvalidArgumentException::class);
71
+ $ this ->expectExceptionMessage (sprintf (
72
+ 'Class %s does not implement the %s interface ' ,
73
+ stdClass::class,
74
+ CacheAdapterInterface::class
75
+ ));
76
+
77
+ ValidatorBuilder::fromYaml (self ::$ yamlDefinition )->setCacheAdapter (stdClass::class);
78
+ }
79
+
80
+ public function testItSetsTheCacheAdapter (): void
81
+ {
82
+ ValidatorBuilder::fromYaml (self ::$ yamlDefinition )
83
+ ->setCacheAdapter ($ this ->createMock (CacheAdapterInterface::class)::class);
84
+
85
+ $ this ->addToAssertionCount (1 );
86
+ }
65
87
}
0 commit comments