|
15 | 15 | use Psr\Cache\CacheItemPoolInterface;
|
16 | 16 | use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
17 | 17 | use Symfony\Component\Validator\Constraints\Callback;
|
| 18 | +use Symfony\Component\Validator\Mapping\Cache\Psr6Cache; |
18 | 19 | use Symfony\Component\Validator\Mapping\ClassMetadata;
|
19 | 20 | use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
|
20 | 21 | use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
|
@@ -109,41 +110,20 @@ public function testCachedMetadata()
|
109 | 110 | */
|
110 | 111 | public function testWriteMetadataToLegacyCache()
|
111 | 112 | {
|
112 |
| - $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock(); |
| 113 | + $cache = new Psr6Cache(new ArrayAdapter()); |
113 | 114 | $factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache);
|
114 | 115 |
|
115 | 116 | $parentClassConstraints = [
|
116 | 117 | new ConstraintA(['groups' => ['Default', 'EntityParent']]),
|
117 | 118 | new ConstraintA(['groups' => ['Default', 'EntityInterfaceA', 'EntityParent']]),
|
118 | 119 | ];
|
119 |
| - $interfaceAConstraints = [ |
120 |
| - new ConstraintA(['groups' => ['Default', 'EntityInterfaceA']]), |
121 |
| - ]; |
122 |
| - |
123 |
| - $cache->expects($this->never()) |
124 |
| - ->method('has'); |
125 |
| - $cache->expects($this->exactly(2)) |
126 |
| - ->method('read') |
127 |
| - ->withConsecutive( |
128 |
| - [$this->equalTo(self::PARENT_CLASS)], |
129 |
| - [$this->equalTo(self::INTERFACE_A_CLASS)] |
130 |
| - ) |
131 |
| - ->willReturn(false); |
132 |
| - $cache->expects($this->exactly(2)) |
133 |
| - ->method('write') |
134 |
| - ->withConsecutive( |
135 |
| - $this->callback(function ($metadata) use ($interfaceAConstraints) { |
136 |
| - return $interfaceAConstraints == $metadata->getConstraints(); |
137 |
| - }), |
138 |
| - $this->callback(function ($metadata) use ($parentClassConstraints) { |
139 |
| - return $parentClassConstraints == $metadata->getConstraints(); |
140 |
| - }) |
141 |
| - ); |
142 | 120 |
|
143 | 121 | $metadata = $factory->getMetadataFor(self::PARENT_CLASS);
|
144 | 122 |
|
145 | 123 | $this->assertEquals(self::PARENT_CLASS, $metadata->getClassName());
|
146 | 124 | $this->assertEquals($parentClassConstraints, $metadata->getConstraints());
|
| 125 | + $this->assertInstanceOf(ClassMetadata::class, $cache->read(self::PARENT_CLASS)); |
| 126 | + $this->assertInstanceOf(ClassMetadata::class, $cache->read(self::INTERFACE_A_CLASS)); |
147 | 127 | }
|
148 | 128 |
|
149 | 129 | /**
|
|
0 commit comments