<commit_before><?php

namespace Botamp\Utils;

use Botamp\Api\BotampObject;
use Botamp\Api\ApiResource;
use Botamp\Client;
use Botamp\TestCase;
use Botamp\Utils;
use GuzzleHttp\Psr7\Response;

class PaginationIteratorTest extends TestCase
{
    private $iterator;
    private $body;
    private $bodyNext;
    private $resourceUrl = 'https://app.botamp.com/api/v1/entities';

    public function setUp()
    {
        $this->body = [
                        'data' =>
                        [
                            [ 'id' => 1, 'type' => 'entities', 'attributes' => ['url' => 'my/url/1'] ],
                            [ 'id' => 2, 'type' => 'entities', 'attributes' => ['url' => 'my/url/2'] ],
                            [ 'id' => 3, 'type' => 'entities', 'attributes' => ['url' => 'my/url/3'] ]
                        ],
                        'links' =>
                        [
                            'self'  => $this->resourceUrl.'?page[number]=1&page[size]=3',
                            'next'  => $this->resourceUrl.'?page[number]=2&page[size]=3',
                            'last'  => $this->resourceUrl.'?page[number]=2&page[size]=3'
                        ]
                    ];

        $this->bodyNext = [
                        'data' =>
                        [
                            [ 'id' => 4, 'type' => 'entities', 'attributes' => ['url' => 'my/url/4'] ],
                            [ 'id' => 5, 'type' => 'entities', 'attributes' => ['url' => 'my/url/5'] ],
                            [ 'id' => 6, 'type' => 'entities', 'attributes' => ['url' => 'my/url/6'] ]
                        ],
                        'links' =>
                        [
                            'self'   => $this->resourceUrl.'?page[number]=2&page[size]=3',
                            'first'  => $this->resourceUrl.'?page[number]=1&page[size]=3',
                            'prev'   => $this->resourceUrl.'?page[number]=1&page[size]=3',
                        ]
                    ];
        $entities = new ApiResource('entities', new Client('123456789'));
        $this->paginationIterator = (new BotampObject($this->body, $entities))->paginationIterator();<commit_msg>Add test PaginationIterator key() method.<commit_after><?php

namespace Botamp\Utils;

use Botamp\Api\BotampObject;
use Botamp\Api\ApiResource;
use Botamp\Client;
use Botamp\TestCase;
use Botamp\Utils;
use GuzzleHttp\Psr7\Response;

class PaginationIteratorTest extends TestCase
{
    private $iterator;
    private $body;
    private $bodyNext;
    private $resourceUrl = 'https://app.botamp.com/api/v1/entities';

    public function setUp()
    {
        $this->body = [
                        'data' =>
                        [
                            [ 'id' => 1, 'type' => 'entities', 'attributes' => ['url' => 'my/url/1'] ],
                            [ 'id' => 2, 'type' => 'entities', 'attributes' => ['url' => 'my/url/2'] ],
                            [ 'id' => 3, 'type' => 'entities', 'attributes' => ['url' => 'my/url/3'] ]
                        ],
                        'links' =>
                        [
                            'self'  => $this->resourceUrl.'?page[number]=1&page[size]=3',
                            'next'  => $this->resourceUrl.'?page[number]=2&page[size]=3',
                            'last'  => $this->resourceUrl.'?page[number]=2&page[size]=3'
                        ]
                    ];

        $this->bodyNext = [
                        'data' =>
                        [
                            [ 'id' => 4, 'type' => 'entities', 'attributes' => ['url' => 'my/url/4'] ],
                            [ 'id' => 5, 'type' => 'entities', 'attributes' => ['url' => 'my/url/5'] ],
                            [ 'id' => 6, 'type' => 'entities', 'attributes' => ['url' => 'my/url/6'] ]
                        ],
                        'links' =>
                        [
                            'self'   => $this->resourceUrl.'?page[number]=2&page[size]=3',
                            'first'  => $this->resourceUrl.'?page[number]=1&page[size]=3',
                            'prev'   => $this->resourceUrl.'?page[number]=1&page[size]=3',
                        ]
                    ];
        $entities = new ApiResource('entities', new Client('123456789'));
        $this->paginationIterator = (new BotampObject($this->body, $entities))->paginationIterator();
    }

    public function testShouldGetCurrentKey()
    {
        $this->assertEquals(0, $this->paginationIterator->key());
        $this->paginationIterator->next();
        $this->assertEquals(1, $this->paginationIterator->key());
{'fraction_non_alphanumeric': 0.18020521590423258, 'fraction_numerical': 0.015391192817443352, 'mean_word_length': 1.4031843862352338, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 101, 'https://': 2, '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': '3739860', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1318, 'n_words': 211}