Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit 47f55bd

Browse files
Merge pull request #77 from alexislefebvre/fix-testCookie
Fix testCookie
2 parents 699bb8c + ec29ac5 commit 47f55bd

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

tests/Controller/DefaultControllerTest.php

+30-9
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,13 @@ public function testCookie()
298298
'Acme\DataFixtures\ORM\LoadTweetData',
299299
]);
300300

301-
$tweetId = 49664;
301+
$firstTweetId = 49664;
302302

303-
$path = '/sinceId/'.$tweetId;
303+
$path = '/sinceId/'.$firstTweetId;
304304

305305
$this->testClient->enableProfiler();
306306

307-
$this->testClient->request('GET', $path);
307+
$crawler = $this->testClient->request('GET', $path);
308308

309309
$this->assertStatusCode(200, $this->testClient);
310310

@@ -317,6 +317,13 @@ public function testCookie()
317317
);
318318
}
319319

320+
// Number of pending tweets
321+
$this->assertStringContainsString(
322+
'3 pending tweets',
323+
$crawler->filter('main.container > div.navigation')
324+
->first()->filter('div.alert-info')->text()
325+
);
326+
320327
// Test the cookie
321328
$cookieJar = $this->testClient->getCookieJar();
322329

@@ -330,24 +337,31 @@ public function testCookie()
330337

331338
// Cookie jar stores string
332339
$this->assertSame(
333-
(string) $tweetId,
340+
(string) $firstTweetId,
334341
$cookieJar->get('lastTweetId')->getValue()
335342
);
336343

337344
// Display next tweet
338-
$nextTweetId = 1210900500;
345+
$nextTweetId = 210900500;
339346

340347
$path = '/sinceId/'.$nextTweetId;
341348

342-
$this->testClient->request('GET', $path);
349+
$crawler = $this->testClient->request('GET', $path);
350+
351+
// Number of pending tweets
352+
$this->assertStringContainsString(
353+
'2 pending tweets',
354+
$crawler->filter('main.container > div.navigation')
355+
->first()->filter('div.alert-info')->text()
356+
);
343357

344358
// Test that the cookie has been updated to the second tweet in
345359
// the database (but first on this page)
346360
$cookieJar = $this->testClient->getCookieJar();
347361

348362
// Cookie jar stores string
349363
$this->assertSame(
350-
(string) $tweetId,
364+
(string) $nextTweetId,
351365
$cookieJar->get('lastTweetId')->getValue()
352366
);
353367

@@ -356,14 +370,21 @@ public function testCookie()
356370

357371
$this->testClient->followRedirects();
358372

359-
$this->testClient->request('GET', $path);
373+
$crawler = $this->testClient->request('GET', $path);
374+
375+
// Number of pending tweets
376+
$this->assertStringContainsString(
377+
'3 pending tweets',
378+
$crawler->filter('main.container > div.navigation')
379+
->first()->filter('div.alert-info')->text()
380+
);
360381

361382
$cookieJar = $this->testClient->getCookieJar();
362383

363384
// Test that the cookie is now the first tweet
364385
// Cookie jar stores string
365386
$this->assertSame(
366-
(string) $tweetId,
387+
(string) $firstTweetId,
367388
$cookieJar->get('lastTweetId')->getValue()
368389
);
369390

0 commit comments

Comments
 (0)