You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
62 lines
2.0 KiB
<?php
|
|
|
|
namespace App\Tests\Controller;
|
|
|
|
use App\DataFixtures\UserFixtures;
|
|
use App\Entity\User;
|
|
use App\Entity\Hero;
|
|
|
|
class UserControllerTest extends RestTestBase
|
|
{
|
|
/**
|
|
* This test verifies that requesting
|
|
*/
|
|
public function testRetrieveUser()
|
|
{
|
|
$this->createRequestBuilder()
|
|
->setMethod('GET')
|
|
->setUri('/api/users')
|
|
->setAcceptType('application/json')
|
|
->addServerParameter('HTTP_X-AUTH-TOKEN', UserFixtures::ADMIN_USER_REFERENCE)
|
|
->request();
|
|
|
|
$response = $this->client->getResponse();
|
|
|
|
$this->assertTrue(
|
|
$response->headers->contains('Content-Type', 'application/json'),
|
|
'the "Content-Type" header is "' . $response->headers->get('Content-Type') . '"' // optional message shown on failure
|
|
);
|
|
|
|
$this->assertEquals(200, $response->getStatusCode(), 'Status code was ' . $response->getStatusCode() . ' but expected 200: ' . $response->getContent());
|
|
}
|
|
|
|
/**
|
|
* This test verifies that requesting
|
|
*/
|
|
public function testRetrieveUserWithID1()
|
|
{
|
|
$this->createRequestBuilder()
|
|
->setMethod('GET')
|
|
->setUri('/api/user/1')
|
|
->setAcceptType('application/json')
|
|
->addServerParameter('HTTP_X-AUTH-TOKEN', UserFixtures::ADMIN_USER_REFERENCE)
|
|
->request();
|
|
|
|
$response = $this->client->getResponse();
|
|
|
|
$this->assertTrue(
|
|
$response->headers->contains('Content-Type', 'application/json'),
|
|
'the "Content-Type" header is "' . $response->headers->get('Content-Type') . '"' // optional message shown on failure
|
|
);
|
|
|
|
$this->assertEquals(200, $response->getStatusCode(), 'Status code was ' . $response->getStatusCode() . ' but expected 200: ' . $response->getContent());
|
|
}
|
|
|
|
public function testUserDefaults()
|
|
{
|
|
$hero = new Hero();
|
|
$this->assertEquals(0, $hero->getStrength());
|
|
}
|
|
|
|
}
|