Last active
May 22, 2020 06:15
-
-
Save andreybolonin/ed01933a562e2ef10f87616b5b02e678 to your computer and use it in GitHub Desktop.
ControllerTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests; | |
use PHPUnit\Framework\TestCase; | |
use Symfony\Component\HttpClient\HttpClient; | |
class ControllerTest extends TestCase | |
{ | |
public function testRead() | |
{ | |
$httpClient = HttpClient::create(['base_uri' => 'http://127.0.0.1:8000']); | |
$response = $httpClient->request('GET', '/controller/read.php'); | |
$this->assertEquals($response->getStatusCode(), 200); | |
} | |
public function testCreate() | |
{ | |
$httpClient = HttpClient::create(['base_uri' => 'http://127.0.0.1:8000']); | |
$response = $httpClient->request('GET', '/controller/create.php'); | |
$this->assertEquals($response->getStatusCode(), 200); | |
} | |
public function testUpdate() | |
{ | |
$httpClient = HttpClient::create(['base_uri' => 'http://127.0.0.1:8000']); | |
$response = $httpClient->request('GET', '/controller/edit.php?id=3'); | |
$this->assertEquals($response->getStatusCode(), 200); | |
} | |
public function testDelete() | |
{ | |
$httpClient = HttpClient::create(['base_uri' => 'http://127.0.0.1:8000']); | |
$response = $httpClient->request('GET', '/controller/delete.php?id=3', ['max_redirects' => 0]); | |
$this->assertEquals($response->getStatusCode(), 302); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment