<commit_before><?php

namespace Flatbase;

use Flatbase\Query\DeleteQuery;
use Flatbase\Query\InsertQuery;
use Flatbase\Query\ReadQuery;

class ReadTest extends FlatbaseTestCase
{
    public function testReadWithNoConditions()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        $query = new ReadQuery();
        $query->setCollection('users');
        $collection = $flatbase->execute($query);
        $this->assertEquals($collection->count(), 4);
    }

    public function testReadWithSingleEqualsCondition()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        // New query
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('age', '=', 24);
        $collection = $flatbase->execute($query);
        $this->assertEquals($collection->count(), 1);
        // New query
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('name', '=', 'Adam');
        $collection = $flatbase->execute($query);
        $this->assertEquals($collection->count(), 3);
        // New query
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('height', '=', "6'4");
        $collection = $flatbase->execute($query);
        $this->assertEquals($collection->count(), 1);
    }

    public function testReadWithMultipleEqualsConditions()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('name', '=', 'Adam');
        $query->addCondition('company', '=', 'Foo Inc');
        $collection = $flatbase->execute($query);
        $this->assertEquals($collection->count(), 2);
    }

    public function testReadWithLessThanCondition()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('age', '<', 25);
        $collection = $flatbase->execute($query);<commit_msg>Refactored some tests using new fluent interface<commit_after><?php

namespace Flatbase;

use Flatbase\Query\DeleteQuery;
use Flatbase\Query\InsertQuery;
use Flatbase\Query\ReadQuery;

class ReadTest extends FlatbaseTestCase
{
    public function testReadWithNoConditions()
    {
        $this->assertEquals($this->getFlatbaseWithSampleData()->read()->in('users')->count(), 4);
    }

    public function testReadWithSingleEqualsCondition()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        $this->assertEquals($flatbase->read()->in('users')->where('age', '=', 24)->count(), 1);
        $this->assertEquals($flatbase->read()->in('users')->where('name', '=', 'Adam')->count(), 3);
        $this->assertEquals($flatbase->read()->in('users')->where('height', '=', "6'4")->count(), 1);
    }

    public function testReadWithMultipleEqualsConditions()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('name', '=', 'Adam');
        $query->addCondition('company', '=', 'Foo Inc');
        $collection = $flatbase->execute($query);
        $this->assertEquals($collection->count(), 2);
    }

    public function testReadWithLessThanCondition()
    {
        $flatbase = $this->getFlatbaseWithSampleData();
        $query = new ReadQuery();
        $query->setCollection('users');
        $query->addCondition('age', '<', 25);
        $collection = $flatbase->execute($query);
{'fraction_non_alphanumeric': 0.17752808988764046, 'fraction_numerical': 0.006179775280898876, 'mean_word_length': 3.311138014527845, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 67, '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': '2926978', 'n_tokens_mistral': 1026, 'n_tokens_neox': 987, 'n_words': 166}