8000 [VarDumper] Code review changes · symfony/symfony@95e83a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 95e83a9

Browse files
committed
[VarDumper] Code review changes
- Change MemcachedCasterTest and use assertDumpMatchesFormat
1 parent f0a6120 commit 95e83a9

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

src/Symfony/Component/VarDumper/Tests/Caster/MemcachedCasterTest.php

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\VarDumper\Caster\MemcachedCaster;
1616
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1717

18+
/**
19+
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
20+
*/
1821
class MemcachedCasterTest extends TestCase
1922
{
2023
use VarDumperTestTrait;
@@ -58,14 +61,9 @@ public function testCastMemcachedWithCustomOptions()
5861
$var = new \Memcached();
5962
$var->addServer('127.0.0.1', 11211);
6063
$var->addServer('127.0.0.2', 11212);
61-
6264
$var->setOptions($this->getCustomOptions());
6365

64-
$expectedOptions = $this->getExpectedOptions($var);
65-
66-
$expectedOptionsAsString = implode(PHP_EOL, $expectedOptions);
67-
68-
$expected = <<<EOTXT
66+
$expected = <<<'EOTXT'
6967
Memcached {
7068
servers: array:2 [
7169
0 => array:3 [
@@ -80,12 +78,41 @@ public function testCastMemcachedWithCustomOptions()
8078
]
8179
]
8280
options: {
83-
$expectedOptionsAsString
81+
OPT_COMPRESSION: %s
82+
OPT_PREFIX_KEY: "%s"
83+
OPT_USER_FLAGS: %i
84+
OPT_STORE_RETRY_COUNT: %i
85+
OPT_HASH: %i
86+
OPT_DISTRIBUTION: %i
87+
OPT_LIBKETAMA_COMPATIBLE: %i
88+
OPT_LIBKETAMA_HASH: %i
89+
OPT_TCP_KEEPALIVE: %i
90+
OPT_BINARY_PROTOCOL: %i
91+
OPT_NO_BLOCK: %i
92+
OPT_TCP_NODELAY: %i
93+
OPT_SOCKET_SEND_SIZE: %i
94+
OPT_SOCKET_RECV_SIZE: %i
95+
OPT_CONNECT_TIMEOUT: %i
96+
OPT_RETRY_TIMEOUT: %i
97+
OPT_DEAD_TIMEOUT: %i
98+
OPT_SEND_TIMEOUT: %i
99+
OPT_RECV_TIMEOUT: %i
100+
OPT_POLL_TIMEOUT: %i
101+
OPT_SERVER_FAILURE_LIMIT: %i
102+
OPT_AUTO_EJECT_HOSTS: %i
103+
OPT_HASH_WITH_PREFIX_KEY: %i
104+
OPT_NOREPLY: %i
105+
OPT_SORT_HOSTS: %i
106+
OPT_USE_UDP: %i
107+
OPT_NUMBER_OF_REPLICAS: %i
108+
OPT_RANDOMIZE_REPLICA_READ: %i
109+
OPT_REMOVE_FAILED_SERVERS: %i
110+
OPT_SERVER_TIMEOUT_LIMIT: %i
84111
}
85112
}
86113
EOTXT;
87114

88-
$this->assertDumpEquals($expected, $var);
115+
$this->assertDumpMatchesFormat($expected, $var);
89116
}
90117

91118
private function getCustomOptions()
@@ -122,24 +149,4 @@ private function getCustomOptions()
122149

123150
return $customOptions;
124151
}
125-
126-
private function getExpectedOptions(\Memcached $memcached)
127-
{
128-
$expectedOptions = array();
129-
$nonDefaultOptions = MemcachedCaster::getMemcachedNonDefaultValueOptions($memcached);
130-
131-
foreach ($nonDefaultOptions as $key => $value) {
132-
if (\is_string($value)) {
133-
$value = '"'.$value.'"';
134-
}
135-
136-
if (\is_bool($value)) {
137-
$value = $value ? 'true' : 'false';
138-
}
139-
140-
$expectedOptions[] = ' '.$key.': '.$value;
141-
}
142-
143-
return $expectedOptions;
144-
}
145152
}

0 commit comments

Comments
 (0)
0