<commit_before><?php namespace Falafel\test\Listing;

use Falafel\Column\ColumnBase;
use Falafel\Criteria\CriteriaBase;
use Falafel\DataSource\DataSourceArray;

class DataSourceArrayTest extends \PHPUnit_Framework_TestCase {


	/**
	 * @dataProvider testFetchRowsDataProvider
	 */
	public function testFetchRows($criteria, $testName)
	{

		$ds = new DataSourceArray(
			array(
				array(
					'id' => 1,
					'name' => '<NAME>',
					'email' => '<EMAIL>',
					'created_at' => mktime(),
					'updated_at' => mktime()
				)
			)
		);

		$rows = $ds->fetchRows($criteria);

		$this->assertInstanceOf('\Iterator', $rows);

		$rows->rewind();
		$first = $rows->current();
		$this->assertArrayHasKey('id', $first);	
		$this->assertArrayHasKey('name', $first);	
		$this->assertArrayHasKey('email', $first);	
		$this->assertArrayHasKey('created_at', $first);	
		$this->assertArrayHasKey('updated_at', $first);	
	}

	/**
	 * @dataProvider testFetchRowsNoMatchDataProvider
	 */
	public function testFetchRowsNoMatch($criteria, $testName)
	{

		$ds = new DataSourceArray(
			array(
				array(
					'id' => 1,
					'name' => '<NAME>',
					'email' => '<EMAIL>',
					'created_at' => mktime(),
					'updated_at' => mktime()
				)
			)
		);

		$rows = $ds->fetchRows($criteria);

		$this->assertInstanceOf('\Iterator', $rows);
		$this->assertEquals(0, count($rows));
	}

	public function testFetchRowsNoMatchDataProvider()
	{<commit_msg>fix: change mktime to time<commit_after><?php namespace Falafel\test\Listing;

use Falafel\Column\ColumnBase;
use Falafel\Criteria\CriteriaBase;
use Falafel\DataSource\DataSourceArray;

class DataSourceArrayTest extends \PHPUnit_Framework_TestCase {


	/**
	 * @dataProvider testFetchRowsDataProvider
	 */
	public function testFetchRows($criteria, $testName)
	{

		$ds = new DataSourceArray(
			array(
				array(
					'id' => 1,
					'name' => '<NAME>',
					'email' => '<EMAIL>',
					'created_at' => time(),
					'updated_at' => time()
				)
			)
		);

		$rows = $ds->fetchRows($criteria);

		$this->assertInstanceOf('\Iterator', $rows);

		$rows->rewind();
		$first = $rows->current();
		$this->assertArrayHasKey('id', $first);	
		$this->assertArrayHasKey('name', $first);	
		$this->assertArrayHasKey('email', $first);	
		$this->assertArrayHasKey('created_at', $first);	
		$this->assertArrayHasKey('updated_at', $first);	
	}

	/**
	 * @dataProvider testFetchRowsNoMatchDataProvider
	 */
	public function testFetchRowsNoMatch($criteria, $testName)
	{

		$ds = new DataSourceArray(
			array(
				array(
					'id' => 1,
					'name' => '<NAME>',
					'email' => '<EMAIL>',
					'created_at' => time(),
					'updated_at' => time()
				)
			)
		);

		$rows = $ds->fetchRows($criteria);

		$this->assertInstanceOf('\Iterator', $rows);
		$this->assertEquals(0, count($rows));
	}

	public function testFetchRowsNoMatchDataProvider()
	{
{'fraction_non_alphanumeric': 0.1784086926042762, 'fraction_numerical': 0.002103049421661409, 'mean_word_length': 3.946273830155979, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, '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': '3420447', 'n_tokens_mistral': 1155, 'n_tokens_neox': 982, 'n_words': 166}