Skip to content

Commit f358ea8

Browse files
author
anahan
committed
More tests refactoring
1 parent a744334 commit f358ea8

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

test/CommandToStringConvertorTest.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010

1111
final class CommandToStringConvertorTest extends TestCase
1212
{
13-
public function dataProvider()
13+
public function dataProvider(): array
1414
{
1515
return [
1616
[
17-
['query' => ['player_id' => 34]],
17+
ov('query', ov('player_id', 34)),
1818
'db.runCommand({query: {player_id: ?}})'
1919
],
2020
[
21-
['query' => ['player_id' => '34']],
21+
ov('query', ov('player_id', '34')),
2222
'db.runCommand({query: {player_id: "?"}})'
2323
],
2424
[
25-
['query' => ['player_id' => ['$in' => ['34', '343']]]],
25+
ov('query', ov('player_id', ov('$in', ['34', '343']))),
2626
'db.runCommand({query: {player_id: {$in: [\'...\']}}})'
2727
],
2828
[
@@ -38,26 +38,16 @@ public function dataProvider()
3838
];
3939
}
4040

41-
private function array2object($array)
42-
{
43-
return json_decode(json_encode($array));
44-
}
45-
4641
/**
4742
* @dataProvider dataProvider
4843
*
49-
* @param array|\stdClass $command
50-
* @param string $expected
44+
* @param object $command
45+
* @param string $expected
5146
*/
52-
public function testConvert($command, string $expected): void
47+
public function testConvert(object $command, string $expected): void
5348
{
5449
$convertor = new JaegerMongoDbCommandConvertor();
5550

56-
$data = $command;
57-
if (\is_array($command)) {
58-
$data = $this->array2object($command);
59-
}
60-
61-
$this->assertEquals($expected, $convertor->convert($data));
51+
$this->assertEquals($expected, $convertor->convert($command));
6252
}
6353
}

0 commit comments

Comments
 (0)