<commit_before><?php
namespace CrudJsonApi\Test\TestCase\Integration\JsonApi;

use CrudJsonApi\Test\TestCase\Integration\JsonApiBaseTestCase;

class PostRequestIntegrationTest extends JsonApiBaseTestCase
{
    /**
     * PhpUnit Data Provider for testing (only) successful POST requests.
     *
     * @return array
     */
    public function postProvider()
    {
        return [
            #
            # Test creating a single-word resource.
            #
            'post-single-word-collection' => [
                '/countries',
                [
                    'data' => [
                        'type' => 'countries',
                        'attributes' => [
                            'code' => 'NZ',
                            'name' => 'New Zealand',
                            'currency_id' => 1,
                            'national_capital_id' => 3
                        ]
                    ]
                ],
                'get-countries-with-pagination.json'
            ],
        ];
    }

    /**
     * @param string $url The endpoint to hit
     * @param string $body JSON API body in CakePHP array format
     * @param string $expectedResponseFile The file to find the expected jsonapi response in
     * @return void
     * @dataProvider postProvider
     */
    public function testPost($url, $body, $expectedResponseFile)
    {
        $this->configRequest([
            'headers' => [
                'Accept' => 'application/vnd.api+json',
                'Content-Type' => 'application/vnd.api+json'
            ],
            'input' => json_encode($body)
        ]);

        # execute the PATCH request
        $this->post($url);
        $this->assertResponseCode(201); # http://jsonapi.org/format/#crud-creating-responses-201
        $this->_assertJsonApiResponseHeaders();
        $this->assertResponseNotEmpty();
        #$this->assertResponseEquals($this->_getExpected('CreatingResources' . DS . 'post-country.json'));
    }
}<commit_msg>Add reminder about this dodgy test<commit_after><?php
namespace CrudJsonApi\Test\TestCase\Integration\JsonApi;

use CrudJsonApi\Test\TestCase\Integration\JsonApiBaseTestCase;

class PostRequestIntegrationTest extends JsonApiBaseTestCase
{
    /**
     * PhpUnit Data Provider for testing (only) successful POST requests.
     *
     * @return array
     */
    public function postProvider()
    {
        return [
            #
            # Test creating a single-word resource.
            #
            'post-single-word-collection' => [
                '/countries',
                [
                    'data' => [
                        'type' => 'countries',
                        'attributes' => [
                            'code' => 'NZ',
                            'name' => 'New Zealand',
                            'currency_id' => 1,
                            'national_capital_id' => 3
                        ]
                    ]
                ],
                'post-country.json'
            ],
        ];
    }

    /**
     * @param string $url The endpoint to hit
     * @param string $body JSON API body in CakePHP array format
     * @param string $expectedResponseFile The file to find the expected jsonapi response in
     * @return void
     * @dataProvider postProvider
     */
    public function testPost($url, $body, $expectedResponseFile)
    {
        $this->configRequest([
            'headers' => [
                'Accept' => 'application/vnd.api+json',
                'Content-Type' => 'application/vnd.api+json'
            ],
            'input' => json_encode($body)
        ]);

        # execute the PATCH request
        $this->post($url);
        $this->assertResponseCode(201); # http://jsonapi.org/format/#crud-creating-responses-201
        $this->_assertJsonApiResponseHeaders();
        $this->assertResponseNotEmpty();

        # This should be the actual test replacing NotEmpty
        # Also the response now comes with all includes by default, this is NOT the intended behavior
        # $this->assertResponseEquals($this->_getExpected('CreatingResources' . DS . 'post-country.json'));
    }
}
{'fraction_non_alphanumeric': 0.11177884615384616, 'fraction_numerical': 0.0038461538461538464, 'mean_word_length': 1.5844720496894409, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7251340', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1039, 'n_words': 235}