<commit_before><?php

namespace fennecweb\ajax\details;

use \fennecweb\WebService as WebService;

class TraitsTest extends \PHPUnit_Framework_TestCase
{

    public function testExecute()
    {
        list($service) = WebService::factory('details/Traits');
        $trait_type_id = '1';
        $results = ($service->execute(array('dbversion' => DEFAULT_DBVERSION, 'trait_type_id' => $trait_type_id)));
        $expected = [
                "values" => [
                     "liana" => "136",
                     "nonvascular" => "832",
                     "forb/herb" => "15090",
                     "suffrutescent" => "90",
                     "procumbent" => "50",
                     "trailing" => "53",
                     "decumbent" => "50",
                     "epiphyte" => "118",
                     "tree" => "11199",
                     "twining" => "23",
                     "climbing plant" => "415",
                     "arborescent" => "3",
                     "graminoid" => "2648",
                     "shrub" => "10038",
                     "large shrub" => "38",
                     "geophyte" => "41",
                     "vine" => "5560",
                     "subshrub" => "2442",
                     "woody" => "90",

                ],
                "trait_type_id" => 1,
                "name" => "PlantHabit",
                "ontology_url" => "eol.org/schema/terms/PlantHabit",
                "trait_format" => "categorical_free",
                "number_of_organisms" => 16425
            ];
        $this->assertEquals($expected, $results);
    }
}<commit_msg>Define test case of trait details webservice<commit_after><?php

namespace fennecweb\ajax\details;

use \fennecweb\WebService as WebService;

class TraitsTest extends \PHPUnit_Framework_TestCase
{

    public function testExecute()
    {
        list($service) = WebService::factory('details/Traits');
        $trait_type_id = '1';
        $results = ($service->execute(array('dbversion' => DEFAULT_DBVERSION, 'trait_type_id' => $trait_type_id)));
        $expected = [
                "values" => [
                     "liana" => "136",
                     "nonvascular" => "832",
                     "forb/herb" => "15090",
                     "suffrutescent" => "90",
                     "procumbent" => "50",
                     "trailing" => "53",
                     "decumbent" => "50",
                     "epiphyte" => "118",
                     "tree" => "11199",
                     "twining" => "23",
                     "climbing plant" => "415",
                     "arborescent" => "3",
                     "graminoid" => "2648",
                     "shrub" => "10038",
                     "large shrub" => "38",
                     "geophyte" => "41",
                     "vine" => "5560",
                     "subshrub" => "2442",
                     "woody" => "90",

                ],
                "trait_type_id" => 1,
                "name" => "PlantHabit",
                "ontology_url" => "eol.org/schema/terms/PlantHabit",
                "trait_format" => "categorical_free",
                "number_of_organisms" => 16425
            ];
        $this->assertEquals($expected, $results);

        $results = ($service->execute(array('dbversion' => DEFAULT_DBVERSION, 'trait_type_id' => $trait_type_id, 'organism_ids' => [134097, 163840, 24718, 73023, 23057])));
        $expected = [
                "values" => [
                     "forb/herb" => "4",
                     "shrub" => "2",
                     "subshrub" => "2"
                ],
                "trait_type_id" => 1,
                "name" => "PlantHabit",
                "ontology_url" => "eol.org/schema/terms/PlantHabit",
                "trait_format" => "categorical_free",
                "number_of_organisms" => 5
            ];
        $this->assertEquals($expected, $results, 'Organism ids provided, should return trait details for only those organisms');

        $results = ($service->execute(array('dbversion' => DEFAULT_DBVERSION, 'trait_type_id' => $trait_type_id, 'organism_ids' => [])));
        $expected = [
            "values" => [],
            "trait_type_id" => 1,
            "name" => "PlantHabit",
            "ontology_url" => "eol.org/schema/terms/PlantHabit",
            "trait_format" => "categorical_free",
            "number_of_organisms" => 0
        ];
        $this->assertEquals($expected, $results, 'Array of organism ids is empty, should return empty values array and 0 as number_of_organisms');
    }
}
{'fraction_non_alphanumeric': 0.15137614678899083, 'fraction_numerical': 0.035168195718654434, 'mean_word_length': 1.4578636607622115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 86, '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': '4931219', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1304, 'n_words': 237}