dev-master
9999999-devSimple util for integration tests in slim framework
The Requires
1.0.0
1.0.0.0Simple util for integration tests in slim framework
The Requires
Wallogit.com
2017 © Pedro Peláez
Simple util for integration tests in slim framework
If you doing integration tests for your app writen in slim framework, you must use this package ;), (*1)
Use five magic methods for create and send request to your app:, (*2)
Use query string in routes., (*3)
Example in: tests/Slim/Test/TestingItTest.php, (*4)
<?php
use Slim\Test\Testing;
class TestingTest extends Testing {
public $app = 'tests/testApp.php';
public function testIndex() {
$this->assertEquals('test', $this->get('/')->getBody());
}
public function testNotExistsPage() {
$response = $this->get('/notExistsPage');
$this->assertContains('404 Page Not Found', $response->getBody());
$this->assertEquals(404, $response->getStatus());
}
public function testDeleteProduct() {
$this->assertEquals('ok', $this->delete('/product')->getBody());
}
public function testDrawApi() {
$response = $this->post('/api/draw', array('key' => 'value'));
$this->assertEquals('value', json_decode($response->getBody())->code);
}
public function testDrawApiWithSendJSON() {
$response = $this->postJson('/api/draw.json', array('key' => 'value'));
$this->assertEquals('value', json_decode($response->getBody())->code);
}
public function testPutNewOrder() {
$response = $this->put('/api/order?force=true', 'orderValue');
$this->assertEquals(
(object) array(
'force' => 'true',
'order' => (object) array('orderKey' => 'orderValue'),
),
json_decode($response->getBody())
);
}
public function testPutNewOrderWithSendJSON() {
$response = $this->putJson('/api/order.json?force=true', array('orderKey' => 'orderValue'));
$this->assertEquals(
(object) array(
'force' => 'true',
'order' => (object) array('orderKey' => 'orderValue'),
),
json_decode($response->getBody())
);
}
}
Simple util for integration tests in slim framework
Simple util for integration tests in slim framework