<commit_before><?php
/**
 * DBSteward unit test for mysql5 extraction errors
 *
 * @package DBSteward
 * @license http://www.opensource.org/licenses/bsd-license.php Simplified BSD License
 * @author <NAME> <<EMAIL>>
 */

require_once 'PHPUnit/Framework/TestCase.php';
require_once __DIR__ . '/../../lib/DBSteward/dbsteward.php';
require_once __DIR__ . '/../mock_output_file_segmenter.php';

/**
 * @group mysql5
 */
class Mysql5ExtractionTest extends PHPUnit_Framework_TestCase {

  public function setUp() {
    // disable pesky output buffering
    while (ob_get_level()) ob_end_clean();

    $this->conn = $GLOBALS['db_config']->mysql5_conn;
    $this->createSchema();
  }
  public function tearDown() {
    $this->dropSchema();

    // re-enable output buffering so phpunit doesn't bitch
    ob_start();
  }

  public function testSchema() {
    $schema = $this->extract('--');
    $this->assertEquals('ExtractionTest', (string)$schema['name']);
  }


  protected function extract($sql) {
    $schemaname = __CLASS__;
    
    $sql = rtrim($sql, ';');
    $sql = "USE $schemaname;\n$sql;";
    $this->query($sql);

    $xml = mysql5::extract_schema($this->conn->get_dbhost(), $this->conn->get_dbport(), $schemaname, $this->conn->get_dbuser(), $this->conn->get_dbpass());
    $dbdoc = simplexml_load_string($xml);
<commit_msg>Ignore this until we need to use Mysql5ExtractionTest<commit_after><?php
/**
 * DBSteward unit test for mysql5 extraction errors
 *
 * @package DBSteward
 * @license http://www.opensource.org/licenses/bsd-license.php Simplified BSD License
 * @author <NAME> <<EMAIL>>
 */

require_once 'PHPUnit/Framework/TestCase.php';
require_once __DIR__ . '/../../lib/DBSteward/dbsteward.php';
require_once __DIR__ . '/../mock_output_file_segmenter.php';

/**
 * @group mysql5
 */
class Mysql5ExtractionTest extends PHPUnit_Framework_TestCase {

  public function setUp() {
    // disable pesky output buffering
    while (ob_get_level()) ob_end_clean();

    $this->conn = $GLOBALS['db_config']->mysql5_conn;
    $this->createSchema();
  }
  public function tearDown() {
    $this->dropSchema();

    // re-enable output buffering so phpunit doesn't bitch
    ob_start();
  }

  // public function testSchema() {
  //   $schema = $this->extract('--');
  //   $this->assertEquals('ExtractionTest', (string)$schema['name']);
  // }


  protected function extract($sql) {
    $schemaname = __CLASS__;
    
    $sql = rtrim($sql, ';');
    $sql = "USE $schemaname;\n$sql;";
    $this->query($sql);

    $xml = mysql5::extract_schema($this->conn->get_dbhost(), $this->conn->get_dbport(), $schemaname, $this->conn->get_dbuser(), $this->conn->get_dbpass());
    $dbdoc = simplexml_load_string($xml);

{'fraction_non_alphanumeric': 0.17269372693726937, 'fraction_numerical': 0.004059040590405904, 'mean_word_length': 3.947080291970803, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '7573547', 'n_tokens_mistral': 917, 'n_tokens_neox': 896, 'n_words': 173}