Skip to content

Commit

Permalink
dos -> unix
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed May 31, 2010
1 parent 2f04229 commit 56236f6
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 106 deletions.
58 changes: 29 additions & 29 deletions test/MysqlAdapterTest.php
@@ -1,29 +1,29 @@
<?php
use ActiveRecord\Column;

include 'helpers/config.php';
require_once dirname(__FILE__) . '/../lib/adapters/MysqlAdapter.php';

class MysqlAdapterTest extends AdapterTest
{
public function set_up($connection_name=null)
{
parent::set_up('mysql');
}

public function test_enum()
{
$author_columns = $this->conn->columns('authors');
$this->assert_equals('enum',$author_columns['some_enum']->raw_type);
$this->assert_equals(Column::STRING,$author_columns['some_enum']->type);
$this->assert_same(null,$author_columns['some_enum']->length);
}

public function test_set_charset()
{
$connection_string = ActiveRecord\Config::instance()->get_connection($this->connection_name);
$conn = ActiveRecord\Connection::instance($connection_string . '?charset=utf8');
$this->assert_equals('SET NAMES ?',$conn->last_query);
}
}
?>
<?php
use ActiveRecord\Column;

include 'helpers/config.php';
require_once dirname(__FILE__) . '/../lib/adapters/MysqlAdapter.php';

class MysqlAdapterTest extends AdapterTest
{
public function set_up($connection_name=null)
{
parent::set_up('mysql');
}

public function test_enum()
{
$author_columns = $this->conn->columns('authors');
$this->assert_equals('enum',$author_columns['some_enum']->raw_type);
$this->assert_equals(Column::STRING,$author_columns['some_enum']->type);
$this->assert_same(null,$author_columns['some_enum']->length);
}

public function test_set_charset()
{
$connection_string = ActiveRecord\Config::instance()->get_connection($this->connection_name);
$conn = ActiveRecord\Connection::instance($connection_string . '?charset=utf8');
$this->assert_equals('SET NAMES ?',$conn->last_query);
}
}
?>
154 changes: 77 additions & 77 deletions test/helpers/DatabaseTest.php
@@ -1,77 +1,77 @@
<?php
require_once 'DatabaseLoader.php';

class DatabaseTest extends SnakeCase_PHPUnit_Framework_TestCase
{
protected $conn;
public static $log = false;

public function set_up($connection_name=null)
{
ActiveRecord\Table::clear_cache();

$config = ActiveRecord\Config::instance();
$this->original_default_connection = $config->get_default_connection();

if ($connection_name)
$config->set_default_connection($connection_name);

if ($connection_name == 'sqlite' || $config->get_default_connection() == 'sqlite')
{
// need to create the db. the adapter specifically does not create it for us.
$this->db = substr(ActiveRecord\Config::instance()->get_connection('sqlite'),9);
new SQLite3($this->db);
}

$this->connection_name = $connection_name;
$this->conn = ActiveRecord\ConnectionManager::get_connection($connection_name);

$GLOBALS['ACTIVERECORD_LOG'] = false;

$loader = new DatabaseLoader($this->conn);
$loader->reset_table_data();

if (self::$log)
$GLOBALS['ACTIVERECORD_LOG'] = true;
}

public function tear_down()
{
if ($this->original_default_connection)
ActiveRecord\Config::instance()->set_default_connection($this->original_default_connection);
}

public function assert_exception_message_contains($contains, $closure)
{
$message = "";

try {
$closure();
} catch (ActiveRecord\UndefinedPropertyException $e) {
$message = $e->getMessage();
}

$this->assert_true(strpos($message,$contains) !== false);
}

/**
* Returns true if $regex matches $actual.
*
* Takes database specific quotes into account by removing them. So, this won't
* work if you have actual quotes in your strings.
*/
public function assert_sql_has($needle, $haystack)
{
$needle = str_replace(array('"','`'),'',$needle);
$haystack = str_replace(array('"','`'),'',$haystack);
return $this->assert_true(strpos($haystack,$needle) !== false);
}

public function assert_sql_doesnt_has($needle, $haystack)
{
$needle = str_replace(array('"','`'),'',$needle);
$haystack = str_replace(array('"','`'),'',$haystack);
return $this->assert_false(strpos($haystack,$needle) !== false);
}
}
?>
<?php
require_once 'DatabaseLoader.php';

class DatabaseTest extends SnakeCase_PHPUnit_Framework_TestCase
{
protected $conn;
public static $log = false;

public function set_up($connection_name=null)
{
ActiveRecord\Table::clear_cache();

$config = ActiveRecord\Config::instance();
$this->original_default_connection = $config->get_default_connection();

if ($connection_name)
$config->set_default_connection($connection_name);

if ($connection_name == 'sqlite' || $config->get_default_connection() == 'sqlite')
{
// need to create the db. the adapter specifically does not create it for us.
$this->db = substr(ActiveRecord\Config::instance()->get_connection('sqlite'),9);
new SQLite3($this->db);
}

$this->connection_name = $connection_name;
$this->conn = ActiveRecord\ConnectionManager::get_connection($connection_name);

$GLOBALS['ACTIVERECORD_LOG'] = false;

$loader = new DatabaseLoader($this->conn);
$loader->reset_table_data();

if (self::$log)
$GLOBALS['ACTIVERECORD_LOG'] = true;
}

public function tear_down()
{
if ($this->original_default_connection)
ActiveRecord\Config::instance()->set_default_connection($this->original_default_connection);
}

public function assert_exception_message_contains($contains, $closure)
{
$message = "";

try {
$closure();
} catch (ActiveRecord\UndefinedPropertyException $e) {
$message = $e->getMessage();
}

$this->assert_true(strpos($message,$contains) !== false);
}

/**
* Returns true if $regex matches $actual.
*
* Takes database specific quotes into account by removing them. So, this won't
* work if you have actual quotes in your strings.
*/
public function assert_sql_has($needle, $haystack)
{
$needle = str_replace(array('"','`'),'',$needle);
$haystack = str_replace(array('"','`'),'',$haystack);
return $this->assert_true(strpos($haystack,$needle) !== false);
}

public function assert_sql_doesnt_has($needle, $haystack)
{
$needle = str_replace(array('"','`'),'',$needle);
$haystack = str_replace(array('"','`'),'',$haystack);
return $this->assert_false(strpos($haystack,$needle) !== false);
}
}
?>

0 comments on commit 56236f6

Please sign in to comment.