Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: liuggio/symfony2-rest-api-the-best-2013-way
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: part3
Choose a base ref
...
head repository: liuggio/symfony2-rest-api-the-best-2013-way
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 4 commits
  • 2 files changed
  • 3 contributors

Commits on Dec 24, 2013

  1. Update README.md

    claudio-dalicandro committed Dec 24, 2013

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8a5c11f View commit details
  2. Merge pull request #2 from claudio-dalicandro/patch-1

    Update README.md
    liuggio committed Dec 24, 2013
    Copy the full SHA
    c73d0e4 View commit details

Commits on Apr 9, 2014

  1. Copy the full SHA
    5e9899c View commit details

Commits on Apr 26, 2014

  1. Merge pull request #6 from yourwebmaker/patch-1

    Add line-breaks on test methods calls
    liuggio committed Apr 26, 2014
    Copy the full SHA
    42f08a7 View commit details
Showing with 30 additions and 8 deletions.
  1. +1 −1 README.md
  2. +29 −7 src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REST API Symfony2: the best 2013 way
====================================

This is the code to support the article at [Symfony2 API REST the best way](http://welcometothebundle.com/rest-api-symfony2-the-best-2013-way/)
This is the code to support the article at [Symfony2 API REST the best way](http://welcometothebundle.com/symfony2-rest-api-the-best-2013-way/)

### Install with Composer

36 changes: 29 additions & 7 deletions src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
@@ -42,7 +42,11 @@ public function testHeadRoute()
$pages = LoadPageData::$pages;
$page = array_pop($pages);

$this->client->request('HEAD', sprintf('/api/v1/pages/%d.json', $page->getId()), array('ACCEPT' => 'application/json'));
$this->client->request(
'HEAD',
sprintf('/api/v1/pages/%d.json', $page->getId()),
array('ACCEPT' => 'application/json')
);
$response = $this->client->getResponse();
$this->assertJsonResponse($response, 200, false);
}
@@ -60,7 +64,8 @@ public function testJsonNewPageAction()
$this->assertEquals(
'{"children":{"title":[],"body":[]}}',
$this->client->getResponse()->getContent(),
$this->client->getResponse()->getContent());
$this->client->getResponse()->getContent()
);
}

public function testJsonPostPageAction()
@@ -98,8 +103,16 @@ public function testJsonPutPageActionShouldModify()
$pages = LoadPageData::$pages;
$page = array_pop($pages);

$this->client->request('GET', sprintf('/api/v1/pages/%d.json', $page->getId()), array('ACCEPT' => 'application/json'));
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent());
$this->client->request(
'GET',
sprintf('/api/v1/pages/%d.json',
$page->getId()), array('ACCEPT' => 'application/json')
);
$this->assertEquals(
200,
$this->client->getResponse()->getStatusCode(),
$this->client->getResponse()->getContent()
);

$this->client->request(
'PUT',
@@ -125,7 +138,11 @@ public function testJsonPutPageActionShouldCreate()
$id = 0;
$this->client->request('GET', sprintf('/api/v1/pages/%d.json', $id), array('ACCEPT' => 'application/json'));

$this->assertEquals(404, $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent());
$this->assertEquals(
404,
$this->client->getResponse()->getStatusCode(),
$this->client->getResponse()->getContent()
);

$this->client->request(
'PUT',
@@ -165,7 +182,12 @@ public function testJsonPatchPageAction()
);
}

protected function assertJsonResponse($response, $statusCode = 200, $checkValidJson = true, $contentType = 'application/json')
protected function assertJsonResponse(
$response,
$statusCode = 200,
$checkValidJson = true,
$contentType = 'application/json'
)
{
$this->assertEquals(
$statusCode, $response->getStatusCode(),
@@ -183,4 +205,4 @@ protected function assertJsonResponse($response, $statusCode = 200, $checkValidJ
);
}
}
}
}