<commit_before><?php
namespace Werkspot\FacebookAdsBundle\Tests\Model\Batch\Request;

use PHPUnit_Framework_TestCase;
use Werkspot\FacebookAdsBundle\Model\AdSet\Params;
use Werkspot\FacebookAdsBundle\Model\Batch\Enum\HttpMethod;
use Werkspot\FacebookAdsBundle\Model\Batch\Request;

class RequestTest extends PHPUnit_Framework_TestCase
{

    /**
     * @dataProvider getMethodEnumData
     *
     * @params Method $method
     */
    public function testMethod(HttpMethod $method)
    {
        $request = $this->getNewEmptyRequest();

        $request->setMethod($method);
        $this->assertEquals(
            ['method' => $method->getValue(), 'relative_url' => null],
            $request->getArray()
        );
    }

    public function testRelativeUrl()
    {
        $relativeUrl = '/example/';
        $request = $this->getNewEmptyRequest();

        $request->setRelativeUrl($relativeUrl);
        $this->assertEquals(
            ['method' => 'GET', 'relative_url' => $relativeUrl],
            $request->getArray()
        );

        $request->setRelativeUrl($relativeUrl, new Params());
        $this->assertEquals(
            ['method' => 'GET', 'relative_url' => $relativeUrl . '?fields='],
            $request->getArray()
        );
    }

    public function testBody()
    {
        $body = 'I can be bet in an POST or PUT request';
        $request = $this->getNewEmptyRequest();

        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_POST));
        $request->setBody($body);
        $this->assertEquals(
            ['method' => 'POST', 'body' => $body, 'relative_url' => null],
            $request->getArray()
        );

        $request = $this->getNewEmptyRequest();
        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_PUT));
        $request->setBody($body);
        $this->assertEquals(
            ['method' => 'PUT', 'body' => $body, 'relative_url' => null],
            $request->getArray()
        );
    }

    /**
     * @expectedException \Exception
     */
    public function testBody_CantSetMethodGET()
    {
        $request = $this->getNewEmptyRequest();
        $request->setBody('this should not be possible');
    }

    /**
     * @expectedException \Exception
     */
    public function testBody_CantSetMethodDELETE()
    {
        $request = $this->getNewEmptyRequest();
        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_DELETE));
        $request->setBody('this should not be possible');
    }

    /**
     * @return array
     */
    public function getMethodEnumData()
    {
        $result = [];
        $fields = HttpMethod::getValidOptions();
        foreach ($fields as $key => $field) {
            $result[$field] = [HttpMethod::get($field)];
        }

        return $result;
    }

    /**
     * @return Request
     */
    private function getNewEmptyRequest()
    {
        $request = new Request();
        $this->assertEquals(
            ['method' => HttpMethod::METHOD_GET, 'relative_url' => null],
            $request->getArray()
        );

        return $request;
    }
}
<commit_msg>make shure testBody_CantSetMethodGET is usting HttpMethod GET<commit_after><?php
namespace Werkspot\FacebookAdsBundle\Tests\Model\Batch\Request;

use PHPUnit_Framework_TestCase;
use Werkspot\FacebookAdsBundle\Model\AdSet\Params;
use Werkspot\FacebookAdsBundle\Model\Batch\Enum\HttpMethod;
use Werkspot\FacebookAdsBundle\Model\Batch\Request;

class RequestTest extends PHPUnit_Framework_TestCase
{

    /**
     * @dataProvider getMethodEnumData
     *
     * @params Method $method
     */
    public function testMethod(HttpMethod $method)
    {
        $request = $this->getNewEmptyRequest();

        $request->setMethod($method);
        $this->assertEquals(
            ['method' => $method->getValue(), 'relative_url' => null],
            $request->getArray()
        );
    }

    public function testRelativeUrl()
    {
        $relativeUrl = '/example/';
        $request = $this->getNewEmptyRequest();

        $request->setRelativeUrl($relativeUrl);
        $this->assertEquals(
            ['method' => 'GET', 'relative_url' => $relativeUrl],
            $request->getArray()
        );

        $request->setRelativeUrl($relativeUrl, new Params());
        $this->assertEquals(
            ['method' => 'GET', 'relative_url' => $relativeUrl . '?fields='],
            $request->getArray()
        );
    }

    public function testBody()
    {
        $body = 'I can be bet in an POST or PUT request';
        $request = $this->getNewEmptyRequest();

        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_POST));
        $request->setBody($body);
        $this->assertEquals(
            ['method' => 'POST', 'body' => $body, 'relative_url' => null],
            $request->getArray()
        );

        $request = $this->getNewEmptyRequest();
        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_PUT));
        $request->setBody($body);
        $this->assertEquals(
            ['method' => 'PUT', 'body' => $body, 'relative_url' => null],
            $request->getArray()
        );
    }

    /**
     * @expectedException \Exception
     */
    public function testBody_CantSetMethodGET()
    {
        $request = $this->getNewEmptyRequest();
        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_GET));
        $request->setBody('this should not be possible');
    }

    /**
     * @expectedException \Exception
     */
    public function testBody_CantSetMethodDELETE()
    {
        $request = $this->getNewEmptyRequest();
        $request->setMethod(HttpMethod::get(HttpMethod::METHOD_DELETE));
        $request->setBody('this should not be possible');
    }

    /**
     * @return array
     */
    public function getMethodEnumData()
    {
        $result = [];
        $fields = HttpMethod::getValidOptions();
        foreach ($fields as $key => $field) {
            $result[$field] = [HttpMethod::get($field)];
        }

        return $result;
    }

    /**
     * @return Request
     */
    private function getNewEmptyRequest()
    {
        $request = new Request();
        $this->assertEquals(
            ['method' => HttpMethod::METHOD_GET, 'relative_url' => null],
            $request->getArray()
        );

        return $request;
    }
}

{'fraction_non_alphanumeric': 0.1493815413891532, 'fraction_numerical': 0.0, 'mean_word_length': 2.4073473797947056, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 92, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1986947', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1765, 'n_words': 313}