<commit_before><?php

namespace Zortje\MySQLKeeper\Tests\Database;

use Zortje\MySQLKeeper\Database\Table;

/**
 * Class TableTest
 *
 * @package Zortje\MySQLKeeper\Tests\Database
 */
class TableTest extends \PHPUnit_Framework_TestCase {

	public function testTableResult() {
		$columns = [
			new Table\Column([
				'Field'   => 'id',
				'Type'    => 'int(10) unsigned',
				'Null'    => 'NO',
				'Key'     => 'MUL',
				'Default' => '',
				'Extra'   => 'auto_increment'
			])
		];

		$table = new Table($columns, []);

		$result = $table->getResult();

		$this->assertGreaterThan(0, count($result));
		$this->assertTrue(in_array('Set as auto_increment but has no primary key', $result[0]));
	}

	public function testResetOfIssues() {
		$columns = [
			new Table\Column([
				'Field'   => 'id',
				'Type'    => 'int(10) unsigned',
				'Null'    => 'NO',
				'Key'     => 'MUL',
				'Default' => '',
				'Extra'   => 'auto_increment'
			])
		];

		/**
		 * Check getResult once and save the result
		 */
		$table = new Table($columns, []);

		$result = $table->getResult();

		/**
		 * Check getResult again and assert saved results array is the same size as the current issues
		 */
		$this->assertSameSize($result, $table->getResult());
	}

	public function testCheckColumns() {
		/**
		 * Column
		 */
		$column = new Table\Column([
			'Field'   => 'id',
			'Type'    => 'int(10) unsigned',
			'Null'    => 'NO',
			'Key'     => 'MUL',
			'Default' => '',
			'Extra'   => 'auto_increment'
		]);

		$columnResult = $column->getResult();

		/**
		 * Table
		 */
		$table = new Table(null, null);

		$tableResult = $table->checkColumns([$column]);

		$this->assertSame($columnResult, $tableResult);
	}

	public function testCheckIsDuplicate() {
		/**
		 * Indices
		 */
		$indices = [
			new Table\Index('id', ['id']),
			new Table\Index('id2', ['id'])
		];

		/**
		 * Table
		 */
		$table = new Table(null, null);

		$result = $table->checkDuplicateIndices($indices);

		$expected = [
			[
				'type'        => 'index',
				'key'         => 'id2',
				'description' => 'Is duplicate of id'
			]
		];

		$this->assertSame($expected, $result);
	}
}<commit_msg>Adding additional tests<commit_after><?php

namespace Zortje\MySQLKeeper\Tests\Database;

use Zortje\MySQLKeeper\Database\Table;

/**
 * Class TableTest
 *
 * @package Zortje\MySQLKeeper\Tests\Database
 */
class TableTest extends \PHPUnit_Framework_TestCase {

	public function testTableResult() {
		$columns = [
			new Table\Column([
				'Field'   => 'id',
				'Type'    => 'int(10) unsigned',
				'Null'    => 'NO',
				'Key'     => 'MUL',
				'Default' => '',
				'Extra'   => 'auto_increment'
			])
		];

		$table = new Table($columns, []);

		$result = $table->getResult();

		$this->assertGreaterThan(0, count($result));
		$this->assertTrue(in_array('Set as auto_increment but has no primary key', $result[0]));
	}

	public function testResetOfIssues() {
		$columns = [
			new Table\Column([
				'Field'   => 'id',
				'Type'    => 'int(10) unsigned',
				'Null'    => 'NO',
				'Key'     => 'MUL',
				'Default' => '',
				'Extra'   => 'auto_increment'
			])
		];

		/**
		 * Check getResult once and save the result
		 */
		$table = new Table($columns, []);

		$result = $table->getResult();

		/**
		 * Check getResult again and assert saved results array is the same size as the current issues
		 */
		$this->assertSameSize($result, $table->getResult());
	}

	public function testCheckColumns() {
		/**
		 * Column
		 */
		$column = new Table\Column([
			'Field'   => 'id',
			'Type'    => 'int(10) unsigned',
			'Null'    => 'NO',
			'Key'     => 'MUL',
			'Default' => '',
			'Extra'   => 'auto_increment'
		]);

		$columnResult = $column->getResult();

		/**
		 * Table
		 */
		$table = new Table(null, null);

		$tableResult = $table->checkColumns([$column]);

		$this->assertSame($columnResult, $tableResult);
	}

	public function testCheckIsDuplicate() {
		/**
		 * Indices
		 */
		$indices = [
			new Table\Index('id', ['id']),
			new Table\Index('id2', ['id'])
		];

		/**
		 * Table
		 */
		$table = new Table(null, null);

		$result = $table->checkDuplicateIndices($indices);

		$expected = [
			[
				'type'        => 'index',
				'key'         => 'id2',
				'description' => 'Is duplicate of id'
			]
		];

		$this->assertSame($expected, $result);
	}

	public function testCheckIsDuplicateEmpty() {
		/**
		 * Indices
		 */
		$indices = [
			new Table\Index('id', ['id']),
			new Table\Index('active', ['active'])
		];

		/**
		 * Table
		 */
		$table = new Table(null, null);

		$result = $table->checkDuplicateIndices($indices);

		$this->assertSame([], $result);
	}
}
{'fraction_non_alphanumeric': 0.19437285223367698, 'fraction_numerical': 0.00429553264604811, 'mean_word_length': 2.823481116584565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, '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': '4598993', 'n_tokens_mistral': 1904, 'n_tokens_neox': 1591, 'n_words': 332}