Skip to content

Instantly share code, notes, and snippets.

@adelatorrefoss
Created May 17, 2019 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adelatorrefoss/662affe0071ce14e8aa761206f28d58e to your computer and use it in GitHub Desktop.
Save adelatorrefoss/662affe0071ce14e8aa761206f28d58e to your computer and use it in GitHub Desktop.
POST Refactor
<?php
namespace Trovit\B2B\Redirect\Tests\integration\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
private $client;
protected function setUp()
{
$this->client = static::createClient();
parent::setUp();
}
/** @test */
public function should_succeed_when_all_mandatory_parameters_are_present()
{
$this->client->request('GET', queryString()->build());
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_brand_is_not_present()
{
$this->client->request('GET', queryString()->withoutBrand()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_country_is_not_present()
{
$this->client->request('GET', queryString()->withoutCountry()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_vertical_is_not_present()
{
$this->client->request('GET', queryString()->withoutVertical()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_page_is_not_present()
{
$this->client->request('GET', queryString()->withoutPage()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_source_id_is_not_present()
{
$this->client->request('GET', queryString()->withoutSourceId()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_page_view_id_is_not_present()
{
$this->client->request('GET', queryString()->withoutPageViewId()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_what_is_not_present()
{
$this->client->request('GET', queryString()->withoutWhat()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_user_ip_is_not_present()
{
$this->client->request('GET', queryString()->withoutUserIp()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_user_agent_is_not_present()
{
$this->client->request('GET', queryString()->withoutUserAgent()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_is_human_is_not_present()
{
$this->client->request('GET', queryString()->withoutIsHuman()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_is_dirified_is_not_present()
{
$this->client->request('GET', queryString()->withoutIsDirified()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_origin_is_not_present()
{
$this->client->request('GET', queryString()->withoutOrigin()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_browser_is_not_present()
{
$this->client->request('GET', queryString()->withoutBrowser()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
/** @test */
public function should_fail_when_section_is_not_present()
{
$this->client->request('GET', queryString()->withoutSection()->build());
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
}
}
function queryString(): QueryStringBuilder
{
return QueryStringBuilder::requestParameters();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment