<commit_before><?php
/**
 * @copyright   2014 Mautic, NP. All rights reserved.
 * @author      Mautic
 *
 * @see        http://mautic.org
 *
 * @license     MIT http://opensource.org/licenses/MIT
 */

namespace Mautic\Tests\Api;

use Mautic\Api\Segments;

class SegmentsTest extends MauticApiTestCase
{
    /**
     * @var Segments
     */
    protected $api;

    public function setUp(): void
    {
        $this->api         = $this->getContext('segments');
        $this->testPayload = [
            'name'        => 'List all GMail contacts',
            'description' => 'Created via API Library unit tests',
            'isGlobal'    => true,
            'filters'     => [
                [
                    'glue'     => 'and',
                    'field'    => 'email',
                    'object'   => 'lead',
                    'type'     => 'email',
                    'filter'   => <EMAIL>',
                    'display'  => null,
                    'operator' => 'like',
                ],
            ],
        ];
    }

    public function testGetList()
    {
        $response = $this->api->getList();
        $this->assertErrors($response);
    }

    public function testGetListOfSpecificIds()
    {
        // Create some items first
        $itemIds  = [];
        $response = $this->api->create($this->testPayload);
        $this->assertErrors($response);
        $itemIds[] = $response[$this->api->itemName()]['id'];
        $response  = $this->api->create($this->testPayload);
        $this->assertErrors($response);
        $itemIds[] = $response[$this->api->itemName()]['id'];

        $search = 'ids:'.implode(',', $itemIds);

        $response = $this->api->getList($search);
        $this->assertErrors($response);
        $this->assertEquals(count($itemIds), $response['total']);<commit_msg>switch segment test to new expected format<commit_after><?php
/**
 * @copyright   2014 Mautic, NP. All rights reserved.
 * @author      Mautic
 *
 * @see        http://mautic.org
 *
 * @license     MIT http://opensource.org/licenses/MIT
 */

namespace Mautic\Tests\Api;

use Mautic\Api\Segments;

class SegmentsTest extends MauticApiTestCase
{
    /**
     * @var Segments
     */
    protected $api;

    public function setUp(): void
    {
        $this->api         = $this->getContext('segments');
        $this->testPayload = [
            'name'        => 'List all GMail contacts',
            'description' => 'Created via API Library unit tests',
            'isGlobal'    => true,
            'filters'     => [
                [
                    'glue'       => 'and',
                    'field'      => 'email',
                    'object'     => 'lead',
                    'type'       => 'email',
                    'properties' => [
                        'filter'   => <EMAIL>',
                    ],
                    'operator'   => 'like',
                ],
            ],
        ];
    }

    public function testGetList()
    {
        $response = $this->api->getList();
        $this->assertErrors($response);
    }

    public function testGetListOfSpecificIds()
    {
        // Create some items first
        $itemIds  = [];
        $response = $this->api->create($this->testPayload);
        $this->assertErrors($response);
        $itemIds[] = $response[$this->api->itemName()]['id'];
        $response  = $this->api->create($this->testPayload);
        $this->assertErrors($response);
        $itemIds[] = $response[$this->api->itemName()]['id'];

        $search = 'ids:'.implode(',', $itemIds);

        $response = $this->api->getList($search);
        $this->assertErrors($response);
        $this->assertEquals(count($itemIds), $response['total']);
{'fraction_non_alphanumeric': 0.1647879763821793, 'fraction_numerical': 0.0021470746108427268, 'mean_word_length': 1.6832253419726422, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 71, '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': '3798948', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1043, 'n_words': 194}