Permalink
Browse files

TodoSeleniumTest (一啟動顯示 3 筆 task)

  • Loading branch information...
1 parent 6b6ab43 commit a0812399ba5f2bcc999a8bd8c5a66be4ec446376 Sam.IO.Hsiao committed Oct 18, 2016
Showing with 46 additions and 0 deletions.
  1. +46 −0 tests/TodoSeleniumTest.php
@@ -0,0 +1,46 @@
+<?php
+
+declare(strict_types = 1);
+
+use App\Task;
+
+class TodoSeleniumTest extends PHPUnit_Extensions_Selenium2TestCase
+{
+ /** @var string */
+ private $rootURL = 'todo2';
+ /** @var int */
+ private $ajaxDelay = 1;
+
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->setBrowser(env('BROWSER'));
+ $this->setBrowserUrl('http://' . env('WEBSERVER_URL') . ':' . env('WEBSERVER_PORT'));
+ $this->setHost(env('SELENIUM_URL'));
+ $this->setPort((int)env('SELENIUM_PORT'));
+ $this->ajaxDelay = (int)env('AJAX_DELAY');
+
+ $app = require __DIR__ . '/../bootstrap/app.php';
+ $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
+ }
+
+ protected function tearDown()
+ {
+ DB::table('tasks')->truncate();
+ parent::tearDown();
+ }
+
+ /** @test */
+ public function 一啟動顯示3筆task()
+ {
+ factory(Task::class)->create(['name' => 'Task 1']);
+ factory(Task::class)->create(['name' => 'Task 2']);
+ factory(Task::class)->create(['name' => 'Task 3']);
+
+ $this->url($this->rootURL);
+
+ $this->assertContains('Task 1', $this->byTag('body')->text());
+ $this->assertContains('Task 2', $this->byTag('body')->text());
+ $this->assertContains('Task 3', $this->byTag('body')->text());
+ }
+}

0 comments on commit a081239

Please sign in to comment.