<commit_before><?php
use Codeception\Util\Stub;
use sweelix\curl\Request;

class GoogleMapTest extends \Codeception\TestCase\Test
{
   /**
	* @var \CodeGuy
	*/
	protected $codeGuy;

	protected $googleMapUrl = 'http://maps.googleapis.com/maps/api/geocode/json';

	protected function _before()
	{
	}

	protected function _after()
	{
	}

	// tests
	public function testResponse()
	{
		$this->codeGuy->wantTo('Run a request and get a response');
		$getParameters = array('address' => '1600 Amphitheatre Parkway, Mountain View, CA', 'sensor' => 'false');
		$request = new Request($this->googleMapUrl);
		$request->setUrlParameters($getParameters);
		$response = $request->execute();
		$this->assertInstanceOf('sweelix\curl\Response', $response);
		$this->assertEquals($response->getStatus(), 200);
		$this->assertTrue(is_array($response->getHeaders()));
		$this->assertNull($response->getHeaderField('non-existing-field'));
		$this->assertNotNull($response->getHeaderField('Content-Type'));
		$this->assertNotNull($response->getRawData());
		$this->assertNotNull($response->getData());
	}

	public function testPost() {
		$this->codeGuy->wantTo('Run a post request');
		$getParameters = array('address' => '1600 Amphitheatre Parkway, Mountain View, CA', 'sensor' => 'false');
		$request = new Request($this->googleMapUrl);
		$request->setMethod('POST');
		$request->setBody(array('bad-body' => true));<commit_msg>Adding tests<commit_after><?php
use Codeception\Util\Stub;
use sweelix\curl\Request;

class GoogleMapTest extends \Codeception\TestCase\Test
{
   /**
	* @var \CodeGuy
	*/
	protected $codeGuy;

	protected $googleMapJSONUrl = 'http://maps.googleapis.com/maps/api/geocode/json';
	protected $googleMapXMLUrl = 'http://maps.googleapis.com/maps/api/geocode/xml';

	protected function _before()
	{
	}

	protected function _after()
	{
	}

	// tests
	public function testJsonResponse()
	{
		$this->codeGuy->wantTo('Run a request and get a JSON response');
		$getParameters = array('address' => '1600 Amphitheatre Parkway, Mountain View, CA', 'sensor' => 'false');
		$request = new Request($this->googleMapJSONUrl);
		$request->setUrlParameters($getParameters);
		$response = $request->execute();
		$this->assertInstanceOf('sweelix\curl\Response', $response);
		$this->assertEquals($response->getStatus(), 200);
		$this->assertTrue(is_array($response->getHeaders()));
		$this->assertNull($response->getHeaderField('non-existing-field'));
		$this->assertNotNull($response->getHeaderField('Content-Type'));
		$this->assertNotNull($response->getRawData());
		$this->assertNotNull($response->getData());
	}
	public function testXmlResponse()
	{
		$this->codeGuy->wantTo('Run a request and get a XML response');
		$getParameters = array('address' => '1600 Amphitheatre Parkway, Mountain View, CA', 'sensor' => 'false');
		$request = new Request($this->googleMapXMLUrl);
		$request->setUrlParameters($getParameters);
		$response = $request->execute();
		$this->assertInstanceOf('sweelix\curl\Response', $response);
		$this->assertEquals($response->getStatus(), 200);
		$this->assertTrue(is_array($response->getHeaders()));
		$this->assertNull($response->getHeaderField('non-existing-field'));
		$this->assertNotNull($response->getHeaderField('Content-Type'));
		$this->assertNotNull($response->getRawData());
		$this->assertNotNull($response->getData());
	}

	public function testPost() {
		$this->codeGuy->wantTo('Run a post request');
		$getParameters = array('address' => '1600 Amphitheatre Parkway, Mountain View, CA', 'sensor' => 'false');
		$request = new Request($this->googleMapJSONUrl);
		$request->setMethod('POST');
		$request->setBody(array('bad-body' => true));
{'fraction_non_alphanumeric': 0.18303327877795963, 'fraction_numerical': 0.007910529187124931, 'mean_word_length': 5.9319470699432895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7632491', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1127, 'n_words': 202}