laravel api phpunit 実行サンプル

laravel api phpunit 実行サンプル


http://localhost/xxxxxx/apis/echo
{ status : OK message : No problem }


>phpunit --color .¥tests¥SimpleApiTest.php

tests SimpleApiTest.php
<?php
class SimpleApiTest extends TestCase &#123;

public function testEchoApi()
&#123;
//call &#36;this->clientは5から廃止された?
&#36;response = &#36;this->call( GET /apis/echo );

&#36;this->assertEquals(200 &#36;response->getStatusCode());

&#36;obj = &#36;response->getData();

&#36;this->assertEquals( OK &#36;obj->status);
&#36;this->assertEquals( No problem &#36;obj->message);
&#125;
&#125;



<logging>
<log type= json target= ./tests/results/logfile.json />
<log type= tap target= ./tests/results/logfile.tap />
<log type= junit target= ./tests/results/logfile.xml logIncompleteSkipped= false />
<log type= testdox-html target= ./tests/results/testdox.html />
<log type= testdox-text target= ./tests/results/testdox.txt />
</logging>