<commit_before><?php

namespace Ayamel\SearchBundle\Tests;

use Ayamel\ApiBundle\ApiTestCase;

/**
 * This set of tests makes sure the API search routes perform as expected.  Most importantly
 * they need to strip unauthoried Resources from the returned results.
 *
 * @package AyamelSearchBundle
 * @author <NAME>
 */
class SearchApiTest extends ApiTestCase
{

    public function setUp()
    {
        // add some dummy resources to query
        $this->clearDatabase();

        $json = $this->getJson('POST', '/api/v1/resources?_key=45678isafgd56789asfgdhf4567', array(), array(), array(
            'CONTENT_TYPE' => 'application/json'
        ), json_encode(array(
            'title' => 'Russia House',
            'type' => 'data',
        )));

        $json = $this->getJson('POST', '/api/v1/resources?_key=45678isafgd56789asfgdhf4567', array(), array(), array(
            'CONTENT_TYPE' => 'application/json'
        ), json_encode(array(
            'title' => 'Sealand House',
            'type' => 'data',
        )));     
        $json = $this->getJson('POST', '/api/v1/resources?_key=45678isafgd56789asfgdhf4567', array(), array(), array(
            'CONTENT_TYPE' => 'application/json'
        ), json_encode(array(
            'title' => 'Maxwell House',
            'type' => 'data',
        )));             
    }

    public function testSetupDummyResources()
    {
        $response = $this->getJson('GET', '/api/v1/resources');
        $this->assertSame(3, (count($response['resources'])));
    }

    /**
     * @depends testSetupDummyResources
     */
    public function testSimpleSearchApi($ids)
    {
        $response = $this->getJson('GET', '/api/v1/resources/search?q=russia');
        $code = $response['response']['code'];
        if (200 != $code) {
            print_r($response);
        }
        // print_r($response);
        $this->assertSame(200, $code);
    }

    /**
     * @depends testSetupDummyResources
     */
    public function testSimpleSearchApiHidesUnauthorizedResources($ids)
    {
        $this->markTestSkipped();
    }

    /**
     * @depends testSetupDummyResources
     */
    public function testAdvancedSearchApi($ids)
    {
        $this->markTestSkipped();
    }

    /**
     * @depends testSetupDummyResources
     */<commit_msg>try using document type, search still doesn't do anytthing obvious<commit_after><?php

namespace Ayamel\SearchBundle\Tests;

use Ayamel\ApiBundle\ApiTestCase;

/**
 * This set of tests makes sure the API search routes perform as expected.  Most importantly
 * they need to strip unauthoried Resources from the returned results.
 *
 * @package AyamelSearchBundle
 * @author <NAME>
 */
class SearchApiTest extends ApiTestCase
{

    public function setUp()
    {
        // add some dummy resources to query
        $this->clearDatabase();

        $json = $this->getJson('POST', '/api/v1/resources?_key=45678isafgd56789asfgdhf4567', array(), array(), array(
            'CONTENT_TYPE' => 'application/json'
        ), json_encode(array(
            'title' => 'Russia House',
            'type' => 'document',
        )));

        $json = $this->getJson('POST', '/api/v1/resources?_key=45678isafgd56789asfgdhf4567', array(), array(), array(
            'CONTENT_TYPE' => 'application/json'
        ), json_encode(array(
            'title' => 'Sealand House',
            'type' => 'document',
        )));     
        $json = $this->getJson('POST', '/api/v1/resources?_key=45678isafgd56789asfgdhf4567', array(), array(), array(
            'CONTENT_TYPE' => 'application/json'
        ), json_encode(array(
            'title' => 'Maxwell House',
            'type' => 'document',
        )));             
    }

    public function testSetupDummyResources()
    {
        $response = $this->getJson('GET', '/api/v1/resources');
        $this->assertSame(3, (count($response['resources'])));
    }

    /**
     * @depends testSetupDummyResources
     */
    public function testSimpleSearchApi($ids)
    {
        $response = $this->getJson('GET', '/api/v1/resources/search?q=russia');
        $code = $response['response']['code'];
        if (200 != $code) {
            print_r($response);
        }
        print_r($response);
        $this->assertSame(200, $code);
    }

    /**
     * @depends testSetupDummyResources
     */
    public function testSimpleSearchApiHidesUnauthorizedResources($ids)
    {
        $this->markTestSkipped();
    }

    /**
     * @depends testSetupDummyResources
     */
    public function testAdvancedSearchApi($ids)
    {
        $this->markTestSkipped();
    }

    /**
     * @depends testSetupDummyResources
     */
{'fraction_non_alphanumeric': 0.14843414843414843, 'fraction_numerical': 0.023166023166023165, 'mean_word_length': 2.4464153732446414, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 43, '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': '6808064', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1378, 'n_words': 267}