<commit_before><?php

/**
 * OneDBTest
 *
 * Date: 09.05.14
 * Time: 19:56
 * User: cgellhorn
 */
class OneDBTest extends PHPUnit_Framework_TestCase
{
	/**
	 * OneDB Adapter
	 *
	 * @var OneDB
	 */
	private static $_db;

	/**
	 * Test DB table
	 *
	 * @var string
	 */
	private $_table = 'data';

	public function setUpBeforeClass()
	{
		self::$_db = OneDB::getInstance(array(
			'database'  => $GLOBALS['db_database'],
			'user'      => $GLOBALS['db_user'],
			'password'  => $GLOBALS['db_password']
		));

		// Init test data and also perform test on query method
		self::$_db->query(
			'CREATE TABLE IF NOT EXISTS '
			. self::$_db->btick($this->_table). ' ('
			. 'id INT(9) NOT NULL PRIMARY KEY AUTO_INCREMENT,'
			. 'name VARCHAR(50) NOT NULL'
			. ') ENGINE = InnoDB'
		);
	}

	public function tearDownAfterClass()
	{
		self::$_db->drop($this->_table);
	}

	public function testGetPDO()
	{
		$this->assertInstanceOf('PDO', self::$_db->getPDO());
	}

	public function testQuote()
	{
		$this->assertEquals("'test'", self::$_db->quote('test'));
	}

	public function testBtick()
	{
		$this->assertEquals("`test`", self::$_db->btick('test'));
	}

	public function testInsert()
	{
		$id = self::$_db->insert($this->_table, array(
			'name' => '<NAME>'
		));

		$this->assertTrue(is_int($id) && $id > 0);
	}

	public function testUpdate()
	{
		$name = '<NAME>';

		self::$_db->update(
			$this->_table,
			array('name' => $name),
			array('id = ?' => 1)
		);

		$result = self::$_db->fetchRow(
			'SELECT * FROM ' . self::$_db->btick($this->_table)
			. ' WHERE ' . self::$_db->btick('id') . ' = 1'
		);

		$this->assertEquals($name, $result['name']);
	}

	public function testFetchAll()
	{
		$result = self::$_db->fetchAll(
			'SELECT * FROM ' . self::$_db->btick($this->_table)
		);

		$this->assertTrue(is_array($result[0]));
		$this->assertArrayHasKey('name', $result[0]);
	}
} <commit_msg>Table property is now static<commit_after><?php

/**
 * OneDBTest
 *
 * Date: 09.05.14
 * Time: 19:56
 * User: cgellhorn
 */
class OneDBTest extends PHPUnit_Framework_TestCase
{
	/**
	 * OneDB Adapter
	 *
	 * @var OneDB
	 */
	private static $_db;

	/**
	 * Test DB table
	 *
	 * @var string
	 */
	private static $_table = 'data';

	public function setUpBeforeClass()
	{
		self::$_db = OneDB::getInstance(array(
			'database'  => $GLOBALS['db_database'],
			'user'      => $GLOBALS['db_user'],
			'password'  => $GLOBALS['db_password']
		));

		// Init test data and also perform test on query method
		self::$_db->query(
			'CREATE TABLE IF NOT EXISTS '
			. self::$_db->btick(self::$_table). ' ('
			. 'id INT(9) NOT NULL PRIMARY KEY AUTO_INCREMENT,'
			. 'name VARCHAR(50) NOT NULL'
			. ') ENGINE = InnoDB'
		);
	}

	public function tearDownAfterClass()
	{
		self::$_db->drop(self::$_table);
	}

	public function testGetPDO()
	{
		$this->assertInstanceOf('PDO', self::$_db->getPDO());
	}

	public function testQuote()
	{
		$this->assertEquals("'test'", self::$_db->quote('test'));
	}

	public function testBtick()
	{
		$this->assertEquals("`test`", self::$_db->btick('test'));
	}

	public function testInsert()
	{
		$id = self::$_db->insert(self::$_table, array(
			'name' => '<NAME>'
		));

		$this->assertTrue(is_int($id) && $id > 0);
	}

	public function testUpdate()
	{
		$name = '<NAME>';

		self::$_db->update(
			self::$_table,
			array('name' => $name),
			array('id = ?' => 1)
		);

		$result = self::$_db->fetchRow(
			'SELECT * FROM ' . self::$_db->btick(self::$_table)
			. ' WHERE ' . self::$_db->btick('id') . ' = 1'
		);

		$this->assertEquals($name, $result['name']);
	}

	public function testFetchAll()
	{
		$result = self::$_db->fetchAll(
			'SELECT * FROM ' . self::$_db->btick(self::$_table)
		);

		$this->assertTrue(is_array($result[0]));
		$this->assertArrayHasKey('name', $result[0]);
	}
} 
{'fraction_non_alphanumeric': 0.21143756558237145, 'fraction_numerical': 0.00944386149003148, 'mean_word_length': 3.561004784688995, 'pattern_counts': {'":': 0, '<': 9, '<?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': '310242', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1409, 'n_words': 265}