I am using PHPUnit to test my registration api that I created in a controller. Function works fine but I don't know how to implement logic to test it via PHPUnit..
My code:
namespace Tests\AppBundle\Entity;
use PHPUnit\Framework\TestCase;
class UserTest extends TestCase
{
public function testBasic()
{
// here I want to test my api with phpUnit
}
}
And in my Controller I have a function that I need to implement:
/**
* @Route("/register", name="register")
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\Common\Annotations\AnnotationException
*/
public function testAction()
{
$this->requirePostParams(['first_name', 'last_name]);
$firstName = $this->data['first_name'];
$lastName = $this->data['last_name'];
$user = $this->get('app')->testIt($firstName, $lastName);
return $this->success($response);
}
Aucun commentaire:
Enregistrer un commentaire