Skip to content

Commit e751ede

Browse files
authored
tests: remove beberlei/assert and replace it by webmozart/assert (already in indirect dependencies) (#185)
1 parent f9490c5 commit e751ede

File tree

4 files changed

+97
-78
lines changed

4 files changed

+97
-78
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"twig/twig": "^2.15.3 || ^3.4.3"
2828
},
2929
"require-dev": {
30-
"beberlei/assert": "^3.3",
3130
"fakerphp/faker": "^1.20",
3231
"friends-of-phpspec/phpspec-code-coverage": "^6.1",
3332
"friendsofphp/php-cs-fixer": "^3.13",
@@ -37,7 +36,8 @@
3736
"phpstan/phpstan": "^1.9",
3837
"rector/rector": "^0.14.7",
3938
"symfony/twig-bridge": "^5.4 || ^6.2@dev",
40-
"symfony/var-dumper": "^5.4 || ^6.2@dev"
39+
"symfony/var-dumper": "^5.4 || ^6.2@dev",
40+
"webmozart/assert": "^1.11"
4141
},
4242
"minimum-stability": "stable",
4343
"autoload": {

spec/Knp/DictionaryBundle/DependencyInjection/Compiler/DictionaryBuildingPassSpec.php

+45-33
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace spec\Knp\DictionaryBundle\DependencyInjection\Compiler;
66

7-
use Assert\Assert;
87
use Knp\DictionaryBundle\DependencyInjection\Compiler\DictionaryBuildingPass;
98
use Knp\DictionaryBundle\DependencyInjection\Compiler\DictionaryRegistrationPass;
109
use Knp\DictionaryBundle\Dictionary;
1110
use Knp\DictionaryBundle\Dictionary\Factory\Aggregate;
1211
use PhpSpec\ObjectBehavior;
1312
use Prophecy\Argument;
1413
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
use Webmozart\Assert\Assert;
1515

1616
final class DictionaryBuildingPassSpec extends ObjectBehavior
1717
{
@@ -35,23 +35,29 @@ function it_builds_a_value_as_key_dictionary_from_the_config(ContainerBuilder $c
3535
$container->setDefinition(
3636
'knp_dictionary.dictionary.dico1',
3737
Argument::that(function ($definition): bool {
38-
Assert::that($definition->getClass())->eq(Dictionary::class);
38+
Assert::eq($definition->getClass(), Dictionary::class);
3939

4040
$factory = $definition->getFactory();
4141

42-
Assert::that($factory[0]->__toString())->eq(Aggregate::class);
42+
Assert::eq((string) $factory[0], Aggregate::class);
4343

44-
Assert::that($factory[1])->eq('create');
44+
Assert::eq($factory[1], 'create');
4545

46-
Assert::that($definition->getArguments())->eq([
47-
'dico1',
46+
Assert::eq(
47+
$definition->getArguments(),
4848
[
49-
'type' => Dictionary::VALUE_AS_KEY,
50-
'content' => ['foo', 'bar', 'baz'],
51-
],
52-
]);
53-
54-
Assert::that($definition->getTags())->eq([DictionaryRegistrationPass::TAG_DICTIONARY => [[]]]);
49+
'dico1',
50+
[
51+
'type' => Dictionary::VALUE_AS_KEY,
52+
'content' => ['foo', 'bar', 'baz'],
53+
],
54+
]
55+
);
56+
57+
Assert::eq(
58+
$definition->getTags(),
59+
[DictionaryRegistrationPass::TAG_DICTIONARY => [[]]]
60+
);
5561

5662
return true;
5763
})
@@ -75,23 +81,26 @@ function it_builds_a_value_dictionary_from_the_config(ContainerBuilder $containe
7581
$container->setDefinition(
7682
'knp_dictionary.dictionary.dico1',
7783
Argument::that(function ($definition): bool {
78-
Assert::that($definition->getClass())->eq(Dictionary::class);
84+
Assert::eq($definition->getClass(), Dictionary::class);
7985

8086
$factory = $definition->getFactory();
8187

82-
Assert::that($factory[0]->__toString())->eq(Aggregate::class);
88+
Assert::eq((string) $factory[0], Aggregate::class);
8389

84-
Assert::that($factory[1])->eq('create');
90+
Assert::eq($factory[1], 'create');
8591

86-
Assert::that($definition->getArguments())->eq([
87-
'dico1',
92+
Assert::eq(
93+
$definition->getArguments(),
8894
[
89-
'type' => Dictionary::VALUE,
90-
'content' => [2 => 'foo', 10 => 'bar', 100 => 'baz'],
91-
],
92-
]);
95+
'dico1',
96+
[
97+
'type' => Dictionary::VALUE,
98+
'content' => [2 => 'foo', 10 => 'bar', 100 => 'baz'],
99+
],
100+
]
101+
);
93102

94-
Assert::that($definition->getTags(), [DictionaryRegistrationPass::TAG_DICTIONARY => [[]]]);
103+
Assert::eq($definition->getTags(), [DictionaryRegistrationPass::TAG_DICTIONARY => [[]]]);
95104

96105
return true;
97106
})
@@ -115,23 +124,26 @@ function it_builds_a_key_value_dictionary_from_the_config(ContainerBuilder $cont
115124
$container->setDefinition(
116125
'knp_dictionary.dictionary.dico1',
117126
Argument::that(function ($definition): bool {
118-
Assert::that($definition->getClass())->eq(Dictionary::class);
127+
Assert::eq($definition->getClass(), Dictionary::class);
119128

120129
$factory = $definition->getFactory();
121130

122-
Assert::that($factory[0]->__toString())->eq(Aggregate::class);
131+
Assert::eq((string) $factory[0], Aggregate::class);
123132

124-
Assert::that($factory[1])->eq('create');
133+
Assert::eq($factory[1], 'create');
125134

126-
Assert::that($definition->getArguments())->eq([
127-
'dico1',
135+
Assert::eq(
136+
$definition->getArguments(),
128137
[
129-
'type' => Dictionary::KEY_VALUE,
130-
'content' => [2 => 'foo', 10 => 'bar', 100 => 'baz'],
131-
],
132-
]);
133-
134-
Assert::that($definition->getTags())->eq([DictionaryRegistrationPass::TAG_DICTIONARY => [[]]]);
138+
'dico1',
139+
[
140+
'type' => Dictionary::KEY_VALUE,
141+
'content' => [2 => 'foo', 10 => 'bar', 100 => 'baz'],
142+
],
143+
]
144+
);
145+
146+
Assert::eq($definition->getTags(), [DictionaryRegistrationPass::TAG_DICTIONARY => [[]]]);
135147

136148
return true;
137149
})

spec/Knp/DictionaryBundle/Dictionary/TraceableSpec.php

+45-38
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace spec\Knp\DictionaryBundle\Dictionary;
66

7-
use Assert\Assert;
87
use Knp\DictionaryBundle\DataCollector\DictionaryDataCollector;
98
use Knp\DictionaryBundle\Dictionary;
109
use Knp\DictionaryBundle\Dictionary\Simple;
1110
use Knp\DictionaryBundle\Dictionary\Traceable;
1211
use PhpSpec\ObjectBehavior;
12+
use Webmozart\Assert\Assert;
1313

1414
final class TraceableSpec extends ObjectBehavior
1515
{
@@ -42,21 +42,22 @@ function it_is_a_dictionary()
4242

4343
function it_has_a_name()
4444
{
45-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
45+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
4646

4747
$this->getName()->shouldReturn('name');
4848

49-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
49+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
5050
}
5151

5252
function it_traces_keys()
5353
{
54-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
54+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
5555

5656
$this->getKeys()->shouldReturn(['foo', 'baz']);
5757

58-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
59-
->eq([
58+
Assert::eq(
59+
iterator_to_array($this->collector->getDictionaries()),
60+
[
6061
'name' => [
6162
[
6263
'key' => 'foo',
@@ -67,18 +68,19 @@ function it_traces_keys()
6768
'value' => null,
6869
],
6970
],
70-
])
71-
;
71+
]
72+
);
7273
}
7374

7475
function it_traces_values()
7576
{
76-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
77+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
7778

7879
$this->getValues()->shouldReturn(['foo' => 'bar', 'baz' => null]);
7980

80-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
81-
->eq([
81+
Assert::eq(
82+
iterator_to_array($this->collector->getDictionaries()),
83+
[
8284
'name' => [
8385
[
8486
'key' => 'foo',
@@ -89,18 +91,19 @@ function it_traces_values()
8991
'value' => null,
9092
],
9193
],
92-
])
93-
;
94+
],
95+
);
9496
}
9597

9698
function it_traces_values_get()
9799
{
98-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
100+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
99101

100102
$this['foo']->shouldReturn('bar');
101103

102-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
103-
->eq([
104+
Assert::eq(
105+
iterator_to_array($this->collector->getDictionaries()),
106+
[
104107
'name' => [
105108
[
106109
'key' => 'foo',
@@ -111,18 +114,19 @@ function it_traces_values_get()
111114
'value' => null,
112115
],
113116
],
114-
])
115-
;
117+
]
118+
);
116119
}
117120

118121
function it_traces_value_set()
119122
{
120-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
123+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
121124

122125
$this['yo'] = 'lo';
123126

124-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
125-
->eq([
127+
Assert::eq(
128+
iterator_to_array($this->collector->getDictionaries()),
129+
[
126130
'name' => [
127131
[
128132
'key' => 'foo',
@@ -137,36 +141,38 @@ function it_traces_value_set()
137141
'value' => 'lo',
138142
],
139143
],
140-
])
141-
;
144+
]
145+
);
142146
}
143147

144148
function it_traces_value_unset()
145149
{
146-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
150+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
147151

148152
unset($this['foo']);
149153

150-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
151-
->eq([
154+
Assert::eq(
155+
iterator_to_array($this->collector->getDictionaries()),
156+
[
152157
'name' => [
153158
[
154159
'key' => 'baz',
155160
'value' => null,
156161
],
157162
],
158-
])
159-
;
163+
]
164+
);
160165
}
161166

162167
function it_traces_key_exists()
163168
{
164-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
169+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
165170

166171
$this->shouldHaveKey('baz');
167172

168-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
169-
->eq([
173+
Assert::eq(
174+
iterator_to_array($this->collector->getDictionaries()),
175+
[
170176
'name' => [
171177
[
172178
'key' => 'foo',
@@ -177,21 +183,22 @@ function it_traces_key_exists()
177183
'value' => null,
178184
],
179185
],
180-
])
181-
;
186+
]
187+
);
182188
}
183189

184190
function it_trace_iteration()
185191
{
186-
Assert::that(iterator_to_array($this->collector->getDictionaries()))->noContent();
192+
Assert::isEmpty(iterator_to_array($this->collector->getDictionaries()));
187193

188194
$this->shouldIterateLike([
189195
'foo' => 'bar',
190196
'baz' => null,
191197
]);
192198

193-
Assert::that(iterator_to_array($this->collector->getDictionaries()))
194-
->eq([
199+
Assert::eq(
200+
iterator_to_array($this->collector->getDictionaries()),
201+
[
195202
'name' => [
196203
[
197204
'key' => 'foo',
@@ -202,8 +209,8 @@ function it_trace_iteration()
202209
'value' => null,
203210
],
204211
],
205-
])
206-
;
212+
]
213+
);
207214
}
208215

209216
function it_delegates_the_count_to_the_other_dictionary()

spec/Knp/DictionaryBundle/Templating/Extension/DictionarySpec.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace spec\Knp\DictionaryBundle\Templating\Extension;
66

7-
use Assert\Assert;
87
use Knp\DictionaryBundle\Dictionary;
98
use Knp\DictionaryBundle\Dictionary\Collection;
109
use Knp\DictionaryBundle\Templating\Extension;
1110
use PhpSpec\ObjectBehavior;
11+
use Webmozart\Assert\Assert;
1212

1313
final class DictionarySpec extends ObjectBehavior
1414
{
@@ -42,16 +42,16 @@ function it_returns_a_dictionary_by_its_name($dico1, $dico2)
4242
$functions = $this->getFunctions();
4343
$callable = current($functions->getWrappedObject())->getCallable();
4444

45-
Assert::that($callable('test'))->eq($dico1->getWrappedObject());
46-
Assert::that($callable('other'))->eq($dico2->getWrappedObject());
45+
Assert::eq($callable('test'), $dico1->getWrappedObject());
46+
Assert::eq($callable('other'), $dico2->getWrappedObject());
4747
}
4848

4949
function it_returns_a_value_from_a_dictionary()
5050
{
5151
$filters = $this->getFilters();
5252
$callable = current($filters->getWrappedObject())->getCallable();
5353

54-
Assert::that($callable('foo', 'test'))->eq('bar');
55-
Assert::that($callable('foo', 'other'))->eq(false);
54+
Assert::eq($callable('foo', 'test'), 'bar');
55+
Assert::eq($callable('foo', 'other'), false);
5656
}
5757
}

0 commit comments

Comments
 (0)