<commit_before><?php

declare(strict_types=1);

namespace Keboola\Test\Backend\CommonPart2;

use Keboola\Csv\CsvFile;
use Keboola\StorageApi\Client;
use Keboola\Test\StorageApiTestCase;

class DataPreviewFilterTest extends StorageApiTestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->_initEmptyTestBuckets();
    }

    public function testDataPreviewWithWhereConditions()
    {
        $csvFile = new CsvFile(tempnam(sys_get_temp_dir(), 'keboola'));
        $csvFile->writeRow(["column_1", "column_2", "column_3"]);
        $csvFile->writeRow(["first",1,2]);
        $csvFile->writeRow(["second",4,5]);
        $tableId = $this->_client->createTable($this->getTestBucketId(), 'conditions', $csvFile);

        $where = [
            [
                "col" => "column_1",
                "op" => "=",
                "val" => "first",
            ]
        ];
        $preview = $this->_client->getTableDataPreview($tableId, ['where' => $where]);

        $this->assertCount(1, Client::parseCsv($preview));
    }
}<commit_msg>First version of test<commit_after><?php

declare(strict_types=1);

namespace Keboola\Test\Backend\CommonPart2;

use Keboola\Csv\CsvFile;
use Keboola\StorageApi\Client;
use Keboola\Test\StorageApiTestCase;

class DataPreviewFilterTest extends StorageApiTestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->_initEmptyTestBuckets();
    }

    public function testDataPreviewWithWhereConditions()
    {
        $csvFile = new CsvFile(tempnam(sys_get_temp_dir(), 'keboola'));
        $csvFile->writeRow(["column_1", "column_2", "column_3"]);
        $csvFile->writeRow(["first",1,2]);
        $csvFile->writeRow(["second",4,5]);
        $tableId = $this->_client->createTable($this->getTestBucketId(), 'conditions', $csvFile);

        $where = [
            [
                "column" => "column_1",
                "whereValues" => "eq",
                "val" => "first",
            ]
        ];
        $preview = $this->_client->getTableDataPreview($tableId, ['whereFilters' => $where]);

        $this->assertCount(1, Client::parseCsv($preview));
    }
}
{'fraction_non_alphanumeric': 0.16232558139534883, 'fraction_numerical': 0.010232558139534883, 'mean_word_length': 2.8826714801444044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '1211379', 'n_tokens_mistral': 698, 'n_tokens_neox': 685, 'n_words': 98}