<commit_before><commit_msg>Test PgLook class<commit_after><?php

include(dirname(__FILE__).'/../../../../test/bootstrap/unit.php');
$db_manager = new sfDatabaseManager($configuration);

class TestTableMap extends PgLookBaseObjectMap
{
  protected function initialize()
  {
    $this->connection = PgLook::getConnection();
    $this->object_class = 'TestTable';
    $this->field_definitions = array('something' => 'PgLookStrType');
  }
}

class TestTable extends PgLookBaseObject
{
}

class PgLookTest extends PgLook
{
  protected static $test;
 
  public static function initialize()
  {
    self::$test = new lime_test();
  }

  public static function saveConnectionsTest($db_manager)
  {
    self::saveConnections($db_manager);
    self::$test->ok(count(self::$connections), 'We have connections');
  }

  public static function getConnectionTest()
  {
    $cnx = self::getConnection();
    self::$test->isa_ok($cnx, 'sfPgLookDatabase', 'We have a sfPgLookDatabase');
    $key = array_pop(array_keys(self::$connections));
    $cnx = self::getConnection($key);
    self::$test->isa_ok($cnx, 'sfPgLookDatabase', 'We have a sfPgLookDatabase named '.$key);
  }

  public static function getMapForTest()
  {
    $class = self::getMapFor('TestTable');
    self::$test->isa_ok($class, 'TestTableMap','We get TestTableMap');
  }
 }

PgLookTest::initialize();
PgLookTest::saveConnectionsTest($db_manager);
PgLookTest::getConnectionTest();
PgLookTest::getMapForTest();

{'fraction_non_alphanumeric': 0.15537303216974674, 'fraction_numerical': 0.0, 'mean_word_length': 5.274678111587983, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, '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': '7215489', 'n_tokens_mistral': 472, 'n_tokens_neox': 470, 'n_words': 86}