Replacement of assertEquals() to assertSame()
This commit is contained in:
@ -53,17 +53,17 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testBeginTransaction()
|
||||
{
|
||||
$this->assertEquals($this->driver, $this->driver->beginTransaction());
|
||||
$this->assertSame($this->driver, $this->driver->beginTransaction());
|
||||
}
|
||||
|
||||
public function testCommit()
|
||||
{
|
||||
$this->assertEquals($this->driver, $this->driver->commit());
|
||||
$this->assertSame($this->driver, $this->driver->commit());
|
||||
}
|
||||
|
||||
public function testRollback()
|
||||
{
|
||||
$this->assertEquals($this->driver, $this->driver->rollback());
|
||||
$this->assertSame($this->driver, $this->driver->rollback());
|
||||
}
|
||||
|
||||
public function testQuery()
|
||||
@ -72,11 +72,11 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$stmt = $this->driver->query('SELECT * FROM table');
|
||||
$this->assertInstanceOf('DbStmt', $stmt);
|
||||
$this->assertEquals('SELECT * FROM table', $stmt->string());
|
||||
$this->assertSame('SELECT * FROM table', $stmt->string());
|
||||
|
||||
$stmt = $this->driver->query('SELECT * FROM table', 'simple');
|
||||
$this->assertInstanceOf('DbStmt', $stmt);
|
||||
$this->assertEquals('SELECT * FROM table', $stmt->string());
|
||||
$this->assertSame('SELECT * FROM table', $stmt->string());
|
||||
}
|
||||
|
||||
public function testInsert()
|
||||
@ -85,7 +85,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
->setDriverQuoteFunction();
|
||||
$bind = array('table.name' => 'tony', 'chair.age' => 21, 'height' => 185);
|
||||
$sql = $this->driver->insert('users', $bind);
|
||||
$this->assertEquals('INSERT INTO `users` (`table`.`name`, `chair`.`age`, `height`) VALUES (tony, 21, 185)', $sql);
|
||||
$this->assertSame('INSERT INTO `users` (`table`.`name`, `chair`.`age`, `height`) VALUES (tony, 21, 185)', $sql);
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
@ -95,7 +95,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$bind = array('table.name' => 'tony', 'chair.age' => 21, 'height' => 185);
|
||||
$sql = $this->driver->update('users', $bind);
|
||||
$this->assertEquals('UPDATE `users` SET `table`.`name`=tony, `chair`.`age`=21, `height`=185', $sql);
|
||||
$this->assertSame('UPDATE `users` SET `table`.`name`=tony, `chair`.`age`=21, `height`=185', $sql);
|
||||
}
|
||||
|
||||
public function testDeleteNoWHERE()
|
||||
@ -103,7 +103,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
$this->setDriverPrepareFunction();
|
||||
|
||||
$sql = $this->driver->delete('users');
|
||||
$this->assertEquals('DELETE FROM `users`', $sql);
|
||||
$this->assertSame('DELETE FROM `users`', $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithWHEREArray()
|
||||
@ -112,7 +112,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
->setDriverQuoteFunction();
|
||||
|
||||
$sql = $this->driver->delete('users', array('name?tony' => new DbExpr('='), 'height?185' => '>'));
|
||||
$this->assertEquals('DELETE FROM `users` WHERE name=tony AND height>185', $sql);
|
||||
$this->assertSame('DELETE FROM `users` WHERE name=tony AND height>185', $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithWHERESimpleCond()
|
||||
@ -120,7 +120,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
$this->setDriverPrepareFunction();
|
||||
|
||||
$sql = $this->driver->delete('users', 'name=tony');
|
||||
$this->assertEquals('DELETE FROM `users` WHERE name=tony', $sql);
|
||||
$this->assertSame('DELETE FROM `users` WHERE name=tony', $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithWHEREKeyArray()
|
||||
@ -128,7 +128,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
$this->setDriverPrepareFunction();
|
||||
|
||||
$sql = $this->driver->delete('users', array('name=tony' => 0));
|
||||
$this->assertEquals('DELETE FROM `users` WHERE name=tony', $sql);
|
||||
$this->assertSame('DELETE FROM `users` WHERE name=tony', $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithWHEREDbExpr()
|
||||
@ -136,7 +136,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase
|
||||
$this->setDriverPrepareFunction();
|
||||
|
||||
$sql = $this->driver->delete('users', new DbExpr('name=tony'));
|
||||
$this->assertEquals('DELETE FROM `users` WHERE name=tony', $sql);
|
||||
$this->assertSame('DELETE FROM `users` WHERE name=tony', $sql);
|
||||
}
|
||||
|
||||
protected function setDriverPrepareFunction()
|
||||
|
@ -18,6 +18,6 @@ class DbExprTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$expr = new DbExpr('THIS IS SQL EXPRESSION');
|
||||
$str = (string) $expr;
|
||||
$this->assertEquals('THIS IS SQL EXPRESSION', $str);
|
||||
$this->assertSame('THIS IS SQL EXPRESSION', $str);
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ class DbStatementTest extends PHPUnit_Framework_TestCase
|
||||
->will($this->returnCallback(array($this, 'driverQuote')));
|
||||
|
||||
$result = $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
|
||||
$this->assertEquals('SELECT * place_val FROM place_val AND new_val', $result);
|
||||
$this->assertSame('SELECT * place_val FROM place_val AND new_val', $result);
|
||||
}
|
||||
|
||||
public function testExecuteNoPlaceholders()
|
||||
@ -102,7 +102,7 @@ class DbStatementTest extends PHPUnit_Framework_TestCase
|
||||
->with($this->anything())
|
||||
->will($this->returnCallback(array($this, 'dbStatementAssemble')));
|
||||
$result = $this->stmt->execute(array());
|
||||
$this->assertEquals('PLAIN SQL', $result);
|
||||
$this->assertSame('PLAIN SQL', $result);
|
||||
}
|
||||
|
||||
public function testFetch()
|
||||
@ -113,20 +113,20 @@ class DbStatementTest extends PHPUnit_Framework_TestCase
|
||||
->with($this->anything())
|
||||
->will($this->returnCallback(array($this, 'dbStatementFetch')));
|
||||
|
||||
$this->assertEquals(11, $this->stmt->fetchField('one'));
|
||||
$this->assertSame(11, $this->stmt->fetchField('one'));
|
||||
$this->assertFalse($this->stmt->fetchField('zero'));
|
||||
|
||||
reset($this->testData);
|
||||
$this->assertEquals(array(11, 21, 31), $this->stmt->fetchColumn('one'));
|
||||
$this->assertSame(array(11, 21, 31), $this->stmt->fetchColumn('one'));
|
||||
|
||||
reset($this->testData);
|
||||
$result = $this->stmt->fetchAll();
|
||||
$this->assertEquals(11, $result[0]->one);
|
||||
$this->assertEquals(32, $result[2]->two);
|
||||
$this->assertSame(11, $result[0]->one);
|
||||
$this->assertSame(32, $result[2]->two);
|
||||
|
||||
reset($this->testData);
|
||||
$result = $this->stmt->fetchPairs();
|
||||
$this->assertEquals(31, $result['one']);
|
||||
$this->assertSame(31, $result['one']);
|
||||
}
|
||||
|
||||
public function dbStatementAssemble($val)
|
||||
|
@ -52,13 +52,13 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
public function testIdentify()
|
||||
{
|
||||
$param = 'param';
|
||||
$this->assertEquals($param, $this->model->identify($param));
|
||||
$this->assertSame($param, $this->model->identify($param));
|
||||
}
|
||||
|
||||
public function testQuote()
|
||||
{
|
||||
$param = 'param';
|
||||
$this->assertEquals($param, $this->model->quote($param));
|
||||
$this->assertSame($param, $this->model->quote($param));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
@ -73,12 +73,12 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->assertEquals('mock', $this->model->update(array('var' => 'val'), 1));
|
||||
$this->assertSame('mock', $this->model->update(array('var' => 'val'), 1));
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$this->assertEquals('mock', $this->model->delete(1));
|
||||
$this->assertSame('mock', $this->model->delete(1));
|
||||
}
|
||||
|
||||
public function testOrder()
|
||||
@ -86,14 +86,14 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$model = new ReflectionClass('Model');
|
||||
$method = $model->getMethod('order');
|
||||
$method->setAccessible(true);
|
||||
$this->assertEquals(' ORDER BY id DESC', $method->invoke($this->model, array('sort' => 'id', 'order' => 'desc')));
|
||||
$this->assertEquals(' ORDER BY name ASC', $method->invoke($this->model, array('sort' => 'name'), array('id', 'name')));
|
||||
$this->assertSame(' ORDER BY id DESC', $method->invoke($this->model, array('sort' => 'id', 'order' => 'desc')));
|
||||
$this->assertSame(' ORDER BY name ASC', $method->invoke($this->model, array('sort' => 'name'), array('id', 'name')));
|
||||
$this->assertEmpty($method->invoke($this->model, array()));
|
||||
|
||||
/**
|
||||
* @TODO: Model::order - check DESC condition - make case insensitive
|
||||
*/
|
||||
$this->assertEquals(' ORDER BY name ASC', $method->invoke($this->model, array('sort' => 'name', 'order' => 'DESC'), array('id', 'name')));
|
||||
$this->assertSame(' ORDER BY name ASC', $method->invoke($this->model, array('sort' => 'name', 'order' => 'DESC'), array('id', 'name')));
|
||||
}
|
||||
|
||||
public function testSearch()
|
||||
@ -103,7 +103,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$method->setAccessible(true);
|
||||
$this->assertEmpty($method->invoke($this->model, array()));
|
||||
$this->assertEmpty($method->invoke($this->model, array('q' => 'in', 'qt' => 'name')));
|
||||
$this->assertEquals('test.name LIKE %on%', $method->invoke($this->model, array('qt' => 'name', 'q' => 'on'), array('name'), 'test'));
|
||||
$this->assertSame('test.name LIKE %on%', $method->invoke($this->model, array('qt' => 'name', 'q' => 'on'), array('name'), 'test'));
|
||||
}
|
||||
|
||||
public function testFetch()
|
||||
@ -122,7 +122,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$method->setAccessible(true);
|
||||
|
||||
$key = $this->getCacheKeyMockGetSet();
|
||||
$this->assertEquals('field', $method->invoke($this->model, 'SELECT', array(), 'field', $key));
|
||||
$this->assertSame('field', $method->invoke($this->model, 'SELECT', array(), 'field', $key));
|
||||
}
|
||||
|
||||
public function testFetchAll()
|
||||
|
@ -65,8 +65,8 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
->getTable("table");
|
||||
$this->assertTablesEqual($expectedTable, $queryTable);
|
||||
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(3, $this->getConnection()->getRowCount('table'));
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(3, $this->getConnection()->getRowCount('table'));
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
@ -118,14 +118,14 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
|
||||
$driver = new MySQLiDriver($this->conf);
|
||||
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(3, $driver->getInsertId());
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => null, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(4, $driver->getInsertId());
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => null, 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(5, $driver->getInsertId());
|
||||
$this->assertEquals(2, $driver->insert('table', array('id' => '5', 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20'), array('id' => 8)));
|
||||
$this->assertEquals(8, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(3, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => null, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(4, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => null, 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(5, $driver->getInsertId());
|
||||
$this->assertSame(2, $driver->insert('table', array('id' => '5', 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20'), array('id' => 8)));
|
||||
$this->assertSame(8, $driver->getInsertId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,8 +139,8 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
|
||||
$driver = new MySQLiDriver($this->conf);
|
||||
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(3, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(3, $driver->getInsertId());
|
||||
}
|
||||
|
||||
public function testTransaction()
|
||||
|
@ -85,10 +85,10 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->setDriverGetConnectionMethod();
|
||||
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
|
||||
$this->assertEquals('OBJECT', $this->stmt->fetch());
|
||||
$this->assertEquals('ARRAY', $this->stmt->fetch(Db::FETCH_NUM));
|
||||
$this->assertEquals('ASSOC', $this->stmt->fetch(Db::FETCH_ASSOC));
|
||||
$this->assertEquals('ARRAY', $this->stmt->fetch(Db::FETCH_BOTH));
|
||||
$this->assertSame('OBJECT', $this->stmt->fetch());
|
||||
$this->assertSame('ARRAY', $this->stmt->fetch(Db::FETCH_NUM));
|
||||
$this->assertSame('ASSOC', $this->stmt->fetch(Db::FETCH_ASSOC));
|
||||
$this->assertSame('ARRAY', $this->stmt->fetch(Db::FETCH_BOTH));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +101,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->setDriverGetConnectionMethod();
|
||||
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
|
||||
$this->assertEquals('OBJECT', $this->stmt->fetchObject());
|
||||
$this->assertSame('OBJECT', $this->stmt->fetchObject());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +114,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->setDriverGetConnectionMethod();
|
||||
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
|
||||
$this->assertEquals('OBJECT', $this->stmt->fetch());
|
||||
$this->assertSame('OBJECT', $this->stmt->fetch());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +143,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
|
||||
->method('getConnection')
|
||||
->will($this->returnValue($mysqliMock));
|
||||
|
||||
$this->assertEquals('AFFECTED_ROWS', $this->stmt->affectedRows());
|
||||
$this->assertSame('AFFECTED_ROWS', $this->stmt->affectedRows());
|
||||
}
|
||||
|
||||
public function testNumRowsNoResult()
|
||||
|
Reference in New Issue
Block a user