From cee7dbc90a1a9af97a7fa2596e6f328d3aa7f179 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Fri, 22 Nov 2013 23:54:20 +0100 Subject: [PATCH] Add simple functional test --- README.md | 6 +++++- phpunit.xml | 18 ++++++++++++++++++ tests/functionals/ApiTest.php | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 phpunit.xml create mode 100644 tests/functionals/ApiTest.php diff --git a/README.md b/README.md index ede4d6d..c8e6737 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ Then you should initialize your database by running: # Test -To run the test suite just use: +For unit tests (using Atoum) use: ./console tests:unit + +For functional tests you'll need phpunit: + + phpunit diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..9660ec8 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests/functionals/ + + + diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php new file mode 100644 index 0000000..8d17c73 --- /dev/null +++ b/tests/functionals/ApiTest.php @@ -0,0 +1,35 @@ +createClient(); + $crawler = $client->request('GET', '/api/entries'); + + $this->assertTrue($client->getResponse()->isOk()); + + + // Assert that the "Content-Type" header is "application/json" + $this->assertTrue( + $client->getResponse()->headers->contains( + 'Content-Type', + 'application/json' + ) + ); + + $this->assertTrue($client->getResponse()->getContent() == '[]'); + } +}