Skip to content

Commit 8059a20

Browse files
DOC-6095 enabled Predis list notebook
1 parent 76f7905 commit 8059a20

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

local_examples/php/DtListTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// EXAMPLE: list_tutorial
2+
// BINDER_ID php-dt-list
23
<?php
34

45
require 'vendor/autoload.php';
@@ -106,10 +107,11 @@ public function testDtList() {
106107
$this->assertEquals('bike:2', $res12);
107108
$this->assertEquals(['bike:1'], $res13);
108109
$this->assertEquals(['bike:2'], $res14);
109-
$r->del('bikes:repairs');
110110
// REMOVE_END
111111

112112
// STEP_START lpush_rpush
113+
$r->del('bikes:repairs');
114+
113115
$res15 = $r->rpush('bikes:repairs', 'bike:1');
114116
echo $res15 . PHP_EOL;
115117
// >>> 1
@@ -131,10 +133,11 @@ public function testDtList() {
131133
$this->assertEquals(2, $res16);
132134
$this->assertEquals(3, $res17);
133135
$this->assertEquals(['bike:important_bike', 'bike:1', 'bike:2'], $res18);
134-
$r->del('bikes:repairs');
135136
// REMOVE_END
136137

137138
// STEP_START variadic
139+
$r->del('bikes:repairs');
140+
138141
$res19 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3');
139142
echo $res19 . PHP_EOL;
140143
// >>> 3
@@ -157,10 +160,11 @@ public function testDtList() {
157160
'bike:2',
158161
'bike:3',
159162
], $res21);
160-
$r->del('bikes:repairs');
161163
// REMOVE_END
162164

163165
// STEP_START lpop_rpop
166+
$r->del('bikes:repairs');
167+
164168
$res22 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3');
165169
echo $res22 . PHP_EOL;
166170
// >>> 3
@@ -206,10 +210,11 @@ public function testDtList() {
206210
$this->assertEquals(5, $res27);
207211
$this->assertEquals('OK', $res28);
208212
$this->assertEquals(['bike:1', 'bike:2', 'bike:3'], $res29);
209-
$r->del('bikes:repairs');
210213
// REMOVE_END
211214

212215
// STEP_START ltrim_end_of_list
216+
$r->del('bikes:repairs');
217+
213218
$res27 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5');
214219
echo $res27 . PHP_EOL;
215220
// >>> 5
@@ -226,10 +231,11 @@ public function testDtList() {
226231
$this->assertEquals(5, $res27);
227232
$this->assertEquals('OK', $res28);
228233
$this->assertEquals(['bike:3', 'bike:4', 'bike:5'], $res29);
229-
$r->del('bikes:repairs');
230234
// REMOVE_END
231235

232236
// STEP_START brpop
237+
$r->del('bikes:repairs');
238+
233239
$res31 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2');
234240
echo $res31 . PHP_EOL;
235241
// >>> 2
@@ -267,10 +273,11 @@ public function testDtList() {
267273
// REMOVE_START
268274
$this->assertEquals(0, $res35);
269275
$this->assertEquals(3, $res36);
270-
$r->del('new_bikes');
271276
// REMOVE_END
272277

273278
// STEP_START rule_1.1
279+
$r->del('new_bikes');
280+
274281
$res37 = $r->set('new_bikes', 'bike:1');
275282
echo $res37 . PHP_EOL;
276283
// >>> True
@@ -297,10 +304,10 @@ public function testDtList() {
297304
} catch (\Predis\Response\ServerException $e) {
298305
$this->assertStringContainsString('wrong kind of value', strtolower($e->getMessage()));
299306
}
300-
$r->del('new_bikes');
301307
// REMOVE_END
302308

303309
// STEP_START rule_2
310+
$r->del('bikes:repairs');
304311
$res36 = $r->lpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3');
305312
echo $res36 . PHP_EOL;
306313
// >>> 3

0 commit comments

Comments
 (0)