Browse Source

Replacement of assertEquals() to assertSame()

master
Vyacheslav Agafonov 13 years ago
parent
commit
0fdcb87653
  1. 6
      tests/ConfigTest.php
  2. 4
      tests/LoadTest.php
  3. 8
      tests/RegistryTest.php
  4. 6
      tests/app/ActionTest.php
  5. 8
      tests/app/AjaxActionTest.php
  6. 14
      tests/app/ErrorActionTest.php
  7. 6
      tests/app/FrontControllerTest.php
  8. 24
      tests/app/PagerActionTest.php
  9. 4
      tests/app/StaticActionTest.php
  10. 14
      tests/app/router/RouteTest.php
  11. 16
      tests/app/router/RouterTest.php
  12. 4
      tests/cache/CacheKeyTest.php
  13. 14
      tests/cache/MemcacheCacheTest.php
  14. 8
      tests/captcha/CaptchaTest.php
  15. 4
      tests/captcha/CaptchaValidatorTest.php
  16. 48
      tests/classes/EnvTest.php
  17. 74
      tests/classes/FormatTest.php
  18. 8
      tests/exception/ErrorHandlerTest.php
  19. 4
      tests/form/FormFieldTest.php
  20. 4
      tests/form/FormTest.php
  21. 8
      tests/i18n/I18NTest.php
  22. 2
      tests/logger/FileLoggerTest.php
  23. 24
      tests/model/DbDriverTest.php
  24. 2
      tests/model/DbExprTest.php
  25. 14
      tests/model/DbStatementTest.php
  26. 18
      tests/model/ModelTest.php
  27. 24
      tests/model/MySQLiDriverTest.php
  28. 14
      tests/model/MySQLiStatementTest.php
  29. 22
      tests/session/SessionTest.php
  30. 2
      tests/util/AutoloadBuilderTestVFS.php
  31. 4
      tests/util/profiler/CommandProfilerTest.php
  32. 2
      tests/util/profiler/ProfilerTest.php
  33. 2
      tests/validator/RegexValidatorTest.php
  34. 4
      tests/view/PHPViewTest.php
  35. 8
      tests/view/helpers/GetViewHelperTest.php

6
tests/ConfigTest.php

@ -44,9 +44,9 @@ class ConfigTest extends PHPUnit_Framework_TestCase
);
Config::set(0, $arr);
$new_arr = Config::get(0);
$this->assertEquals('ConfigArray', get_class($new_arr));
$this->assertEquals('four', $new_arr->offsetGet(4));
$this->assertEquals(1, $new_arr->one);
$this->assertSame('ConfigArray', get_class($new_arr));
$this->assertSame('four', $new_arr->offsetGet(4));
$this->assertSame(1, $new_arr->one);
$this->assertNotEquals(1, $new_arr->offsetGet('two'));
$this->setExpectedException('GeneralException', 'Configuration variable');

4
tests/LoadTest.php

@ -84,7 +84,7 @@ class LoadTest extends PHPUnit_Framework_TestCase
Load::setAutoloadFrom(self::$file);
$autoload = require(self::$file);
$this->assertEquals(self::$autoload_array, $autoload);
$this->assertSame(self::$autoload_array, $autoload);
Load::autoload('Db');
}
@ -100,7 +100,7 @@ class LoadTest extends PHPUnit_Framework_TestCase
Load::setAutoloadFrom(self::$file);
$autoload = require(self::$file);
$this->assertEquals(self::$autoload_array, $autoload);
$this->assertSame(self::$autoload_array, $autoload);
}
public function testAutoloadArrayExists()

8
tests/RegistryTest.php

@ -45,14 +45,14 @@ class RegistryTest extends PHPUnit_Framework_TestCase
{
Registry::set(1, 1);
Registry::set('two', 2);
$this->assertEquals(Registry::get(1), $this->_registry->get(1));
$this->assertEquals(2, Registry::get('two'));
$this->assertSame(Registry::get(1), $this->_registry->get(1));
$this->assertSame(2, Registry::get('two'));
}
public function testGet()
{
$this->assertEquals(Registry::get(1), $this->_registry->get(1));
$this->assertEquals(Registry::get('two'), 2);
$this->assertSame(Registry::get(1), $this->_registry->get(1));
$this->assertSame(Registry::get('two'), 2);
$this->assertNull(Registry::get(4));
}

6
tests/app/ActionTest.php

@ -25,7 +25,7 @@ class ActionTest extends Action_TestCase
}
Env::setParams(array('param1' => 'value1', 'param2' => 'value2'));
$action = $this->getMockForAbstractClass('Action' );
$this->assertEquals('value1', $action->param1);
$this->assertSame('value1', $action->param1);
}
/**
@ -45,7 +45,7 @@ class ActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = $this->getMockForAbstractClass('Action', array(), 'ActionMock');
$result = $action->fetch();
$this->assertEquals('/actions/to/SomeTemplate', $result['template']);
$this->assertSame('/actions/to/SomeTemplate', $result['template']);
}
/**
@ -61,7 +61,7 @@ class ActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = $this->getMockForAbstractClass('Action', array(), 'ActionMock');
$result = $action->fetch();
$this->assertEquals('/actions//Acti', $result['template']);
$this->assertSame('/actions//Acti', $result['template']);
}
/**

8
tests/app/AjaxActionTest.php

@ -42,8 +42,8 @@ class AjaxActionTest extends Action_TestCase
$action = $this->getMockForAbstractClass('AjaxAction' );
$action->data = array('var' => 'val');
$result = $action->fetch();
$this->assertEquals('/actions//ajax', $result['template']);
$this->assertEquals('{"var":"val"}', $result['data']);
$this->assertSame('/actions//ajax', $result['template']);
$this->assertSame('{"var":"val"}', $result['data']);
}
/**
@ -60,7 +60,7 @@ class AjaxActionTest extends Action_TestCase
$action = $this->getMockForAbstractClass('AjaxAction' );
$action->data = array('var' => 'val');
$result = $action->fetch();
$this->assertEquals('/actions//ajax', $result['template']);
$this->assertEquals( $action->data, $result['data']);
$this->assertSame('/actions//ajax', $result['template']);
$this->assertSame( $action->data, $result['data']);
}
}

14
tests/app/ErrorActionTest.php

@ -38,7 +38,7 @@ class ErrorActionTest extends Action_TestCase
$this->setConstants(false);
$exception = $this->getMock('ErrorException', array(), array('', 0, E_NOTICE));
$action = new ErrorAction($exception);
$this->assertEquals($exception, $action->exception);
$this->assertSame($exception, $action->exception);
}
/**
@ -49,7 +49,7 @@ class ErrorActionTest extends Action_TestCase
$this->setConstants(false);
$exception = $this->getMock('ErrorException', array(), array('', 0, E_WARNING));
$action = new ErrorAction($exception);
$this->assertEquals($exception, $action->exception);
$this->assertSame($exception, $action->exception);
}
/**
@ -60,7 +60,7 @@ class ErrorActionTest extends Action_TestCase
$this->setConstants(false);
$exception = $this->getMock('ErrorException', array(), array('', 0, E_ERROR));
$action = new ErrorAction($exception);
$this->assertEquals($exception, $action->exception);
$this->assertSame($exception, $action->exception);
}
/**
@ -71,7 +71,7 @@ class ErrorActionTest extends Action_TestCase
$this->setConstants(false);
$exception = $this->getMock('ErrorException', array(), array('', 0, 211));
$action = new ErrorAction($exception);
$this->assertEquals($exception, $action->exception);
$this->assertSame($exception, $action->exception);
}
@ -88,7 +88,7 @@ class ErrorActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = new ErrorAction($exception);
$result = $action->fetch();
$this->assertEquals('/actions/500', $result['template']);
$this->assertSame('/actions/500', $result['template']);
}
/**
@ -103,7 +103,7 @@ class ErrorActionTest extends Action_TestCase
->will($this->returnValue(array('one' => array('class' => 'AjaxAction'))));
$action = new ErrorAction($exception);
$this->assertEquals($exception, $action->exception);
$this->assertSame($exception, $action->exception);
}
/**
@ -118,7 +118,7 @@ class ErrorActionTest extends Action_TestCase
->will($this->returnValue(array('one' => array('class' => 'Action'))));
$action = new ErrorAction($exception);
$this->assertEquals($exception, $action->exception);
$this->assertSame($exception, $action->exception);
}
private function setConstants($val = false)

6
tests/app/FrontControllerTest.php

@ -79,7 +79,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
{
$this->setConstants(false);
$controller = FrontController::getInstance();
$this->assertEquals($controller, $controller->setView('View'));
$this->assertSame($controller, $controller->setView('View'));
}
/**
@ -110,9 +110,9 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
{
$this->setConstants(false);
$controller = FrontController::getInstance();
$this->assertEquals('', $controller->getBaseUrl());
$this->assertSame('', $controller->getBaseUrl());
$controller->setBaseUrl('/index/');
$this->assertEquals('/index', $controller->getBaseUrl());
$this->assertSame('/index', $controller->getBaseUrl());
}
/**

24
tests/app/PagerActionTest.php

@ -25,9 +25,9 @@ class PagerActionTest extends Action_TestCase
define('DEBUG', false);
}
$action = $this->getMockForAbstractClass('PagerAction');
$this->assertEquals(20, $action->getLimit());
$this->assertSame(20, $action->getLimit());
$action = $this->getMockForAbstractClass('PagerAction', array(50));
$this->assertEquals(50, $action->getLimit());
$this->assertSame(50, $action->getLimit());
}
/**
@ -40,19 +40,19 @@ class PagerActionTest extends Action_TestCase
}
$action = $this->getMockForAbstractClass('PagerAction');
$action->setCount(50);
$this->assertEquals(1, $action->page);
$this->assertEquals(0, $action->getOffset());
$this->assertSame(1, $action->page);
$this->assertSame(0, $action->getOffset());
$_GET['p'] = 'last';
$action->setCount(50);
$this->assertEquals(3, $action->page);
$this->assertEquals(40, $action->getOffset());
$this->assertSame(3, $action->page);
$this->assertSame(40, $action->getOffset());
$_GET['p'] = 2;
$action->setCount(50);
$this->assertEquals(2, $action->page);
$this->assertEquals(20, $action->getOffset());
$this->assertSame(2, $action->page);
$this->assertSame(20, $action->getOffset());
$_GET['p'] = -3;
$action->setCount(50);
$this->assertEquals(1, $action->page);
$this->assertSame(1, $action->page);
}
/**
@ -64,7 +64,7 @@ class PagerActionTest extends Action_TestCase
define('DEBUG', false);
}
$action = $this->getMockForAbstractClass('PagerAction');
$this->assertEquals(0, $action->getOffset());
$this->assertSame(0, $action->getOffset());
}
/**
@ -80,7 +80,7 @@ class PagerActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = $this->getMockForAbstractClass('PagerAction', array(), 'PagerActionMock');
$result = $action->fetch();
$this->assertEquals('/actions/PagerActi', $result['template']);
$this->assertSame('/actions/PagerActi', $result['template']);
}
/**
@ -96,6 +96,6 @@ class PagerActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = $this->getMockForAbstractClass('PagerAction');
$result = $action->fetch();
$this->assertEquals('/actions/SomeTemplate', $result['template']);
$this->assertSame('/actions/SomeTemplate', $result['template']);
}
}

4
tests/app/StaticActionTest.php

@ -29,7 +29,7 @@ class StaticActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = $this->getMockForAbstractClass('StaticAction', array(), 'StaticActionMock');
$result = $action->fetch();
$this->assertEquals('/static/StaticActi', $result['template']);
$this->assertSame('/static/StaticActi', $result['template']);
}
/**
@ -45,6 +45,6 @@ class StaticActionTest extends Action_TestCase
$controller->setView('SomeView');
$action = $this->getMockForAbstractClass('StaticAction', array(), 'StaticActionMock');
$result = $action->fetch();
$this->assertEquals('/static/SomeTemplate', $result['template']);
$this->assertSame('/static/SomeTemplate', $result['template']);
}
}

14
tests/app/router/RouteTest.php

@ -18,8 +18,8 @@ class RouteTest extends PHPUnit_Framework_TestCase
public function testConstructNoParams()
{
$route = new Route('index', 'user');
$this->assertEquals('userAction', $route->getAction());
$this->assertEquals('Layout', $route->getLayout());
$this->assertSame('userAction', $route->getAction());
$this->assertSame('Layout', $route->getLayout());
$this->assertEmpty($route->getParams());
$this->assertAttributeEquals('index', 'route', $route);
}
@ -28,7 +28,7 @@ class RouteTest extends PHPUnit_Framework_TestCase
{
$route = new Route('index', 'user', array('name' => 'tony', 'role' => 'user'));
$this->assertArrayHasKey('role', $route->getParams());
$this->assertEquals(array('name' => 'tony', 'role' => 'user'), $route->getParams());
$this->assertSame(array('name' => 'tony', 'role' => 'user'), $route->getParams());
}
public function testMatchDiffCount()
@ -50,22 +50,22 @@ class RouteTest extends PHPUnit_Framework_TestCase
{
$route = new Route('user/account/:id', 'user');
$this->assertTrue($route->match(array('user', 'account', '142')));
$this->assertEquals(array('id' => '142'), $route->getParams());
$this->assertSame(array('id' => '142'), $route->getParams());
}
public function testMatchDiffPregParts()
{
$route = new Route('user/account/(?<key>value)', 'user');
$this->assertFalse($route->match(array('user', 'account', 'wrong')));
$this->assertEquals(0, count($route->getParams()));
$this->assertSame(0, count($route->getParams()));
}
public function testMatchPregPasses()
{
$route = new Route('user/account/(?<key>[a-z]+)', 'user');
$this->assertTrue($route->match(array('user', 'account', 'value')));
$this->assertEquals(array('key' => 'value'), $route->getParams());
$this->assertEquals(1, count($route->getParams()));
$this->assertSame(array('key' => 'value'), $route->getParams());
$this->assertSame(1, count($route->getParams()));
}
/**

16
tests/app/router/RouterTest.php

@ -28,9 +28,9 @@ class RouterTest extends PHPUnit_Framework_TestCase
$router = new Router();
$router->add('user', 'user/account/:id', 'user');
$route = $router->route('user/account/213');
$this->assertEquals(1, count($route->getParams()));
$this->assertEquals(array('id' => 213), $route->getParams());
$this->assertEquals('user', $router->getRouteName());
$this->assertSame(1, count($route->getParams()));
$this->assertSame(array('id' => 213), $route->getParams());
$this->assertSame('user', $router->getRouteName());
}
public function testRouterMultipleRoutes()
@ -39,12 +39,12 @@ class RouterTest extends PHPUnit_Framework_TestCase
$router->add('user', 'user/account/:id', 'user');
$router->add('sale', 'sale/order/:id', 'user');
$route = $router->route('user/account/213');
$this->assertEquals('user', $router->getRouteName());
$this->assertEquals(1, count($route->getParams()));
$this->assertEquals(array('id' => 213), $route->getParams());
$this->assertSame('user', $router->getRouteName());
$this->assertSame(1, count($route->getParams()));
$this->assertSame(array('id' => 213), $route->getParams());
$route = $router->route('sale/order/22');
$this->assertEquals('sale', $router->getRouteName());
$this->assertEquals(array('id' => 22), $route->getParams());
$this->assertSame('sale', $router->getRouteName());
$this->assertSame(array('id' => 22), $route->getParams());
}
public function testRouteNotmatch()

4
tests/cache/CacheKeyTest.php

@ -49,7 +49,7 @@ class CacheKeyTest extends PHPUnit_Framework_TestCase
$getExpireMethod = new ReflectionMethod('CacheKey', 'getExpire');
$getExpireMethod->setAccessible(TRUE);
$this->assertEquals(100, $getExpireMethod->invoke($this->cache));
$this->assertSame(100, $getExpireMethod->invoke($this->cache));
}
public function testGetSet()
@ -66,7 +66,7 @@ class CacheKeyTest extends PHPUnit_Framework_TestCase
$this->cache = new CacheKey($mockCacher, 'any');
$this->cache->set('some');
$this->assertEquals('some', $this->cache->get());
$this->assertSame('some', $this->cache->get());
}
public function testDel()

14
tests/cache/MemcacheCacheTest.php

@ -47,7 +47,7 @@ class MemcacheCacheTest extends PHPUnit_Framework_TestCase
{
$memcache = new MemcacheCache(array());
$this->assertTrue($memcache->add('key', 'value'));
$this->assertEquals('value', $memcache->get('key'));
$this->assertSame('value', $memcache->get('key'));
$this->assertFalse($memcache->add('key', 'newvalue'));
}
@ -60,9 +60,9 @@ class MemcacheCacheTest extends PHPUnit_Framework_TestCase
$memcache->add('three', 'three');
$this->assertTrue($memcache->increment('one'));
$this->assertEquals(2, $memcache->get('one'));
$this->assertSame(2, $memcache->get('one'));
$this->assertTrue($memcache->decrement('two'));
$this->assertEquals(1, $memcache->get('two'));
$this->assertSame(1, $memcache->get('two'));
$this->assertFalse($memcache->decrement('three'));
}
@ -75,7 +75,7 @@ class MemcacheCacheTest extends PHPUnit_Framework_TestCase
$memcache->add('two', 2);
$memcache->del('one');
$this->assertEquals(2, $memcache->get('two'));
$this->assertSame(2, $memcache->get('two'));
$this->assertFalse($memcache->get('one'));
}
@ -87,7 +87,7 @@ class MemcacheCacheTest extends PHPUnit_Framework_TestCase
$memcache->add('two', 2);
$memcache->add('three', 'three');
$this->assertEquals('three', 'three');
$this->assertSame('three', 'three');
$memcache->flush();
@ -105,8 +105,8 @@ class MemcacheCacheTest extends PHPUnit_Framework_TestCase
$memcache->set('one', 30);
$memcache->replace('three', 3);
$this->assertEquals(30, $memcache->get('one'));
$this->assertEquals(3, $memcache->get('three'));
$this->assertSame(30, $memcache->get('one'));
$this->assertSame(3, $memcache->get('three'));
}
protected function newCallback($className)

8
tests/captcha/CaptchaTest.php

@ -68,9 +68,9 @@ class CaptchaTest extends PHPUnit_Framework_TestCase
$code = Session::get('_ccode');
$this->assertNotEmpty($token);
$this->assertNotEmpty($code);
$this->assertEquals(5, strlen($code));
$this->assertEquals(Session::get('_ctoken'), $token);
$this->assertEquals(32, strlen($token));
$this->assertSame(5, strlen($code));
$this->assertSame(Session::get('_ctoken'), $token);
$this->assertSame(32, strlen($token));
}
public function testCheckCode()
@ -78,7 +78,7 @@ class CaptchaTest extends PHPUnit_Framework_TestCase
$token = Session::get('_ctoken');
$code = Session::get('_ccode');
$this->assertFalse($this->captcha->checkCode($token . 'asd', $code));
$this->assertEquals(Session::get('_ctoken'), $token);
$this->assertSame(Session::get('_ctoken'), $token);
$this->assertTrue($this->captcha->checkCode($token, $code));
$this->assertNull(Session::get('_ctoken'));
}

4
tests/captcha/CaptchaValidatorTest.php

@ -31,13 +31,13 @@ class CaptchaValidatorTest extends PHPUnit_Framework_TestCase
$validator = new CaptchaValidator();
$this->assertTrue($validator->isValid(null, array('ctoken' => $token, 'ccode' => $code)));
$this->assertFalse($validator->isValid(null, array('ctoken' => $token . 'asd', 'ccode' => $code)));
$this->assertEquals('Entered code wrong', $validator->getMessage());
$this->assertSame('Entered code wrong', $validator->getMessage());
}
public function testIsValidInvalid()
{
$validator = new CaptchaValidator();
$this->assertFalse($validator->isValid(null, array()));
$this->assertEquals('Entered code wrong', $validator->getMessage());
$this->assertSame('Entered code wrong', $validator->getMessage());
}
}

48
tests/classes/EnvTest.php

@ -28,9 +28,9 @@ class EnvTest extends PHPUnit_Framework_TestCase
define('DEBUG', false);
}
$_SERVER['REQUEST_URI'] = '/test/index.php?id=1&test=wet&id_theme=512';
$this->assertEquals('/test/index.php', Env::getRequestUri());
$this->assertSame('/test/index.php', Env::getRequestUri());
$_SERVER['REQUEST_URI'] = '/tes?t/index.php?id=1&test=wet&id_theme=512';
$this->assertEquals('/test/index.php', Env::getRequestUri());
$this->assertSame('/test/index.php', Env::getRequestUri());
}
/**
@ -48,13 +48,13 @@ class EnvTest extends PHPUnit_Framework_TestCase
FrontController::getInstance()->setBaseUrl('/test');
$_SERVER['REQUEST_URI'] = '/test/index.php?id=1&test=wet&id_theme=512';
$this->assertEquals('/index.php', Env::getRequestUri(true));
$this->assertSame('/index.php', Env::getRequestUri(true));
}
public function testServer()
{
$this->assertEquals($_SERVER, Env::Server());
$this->assertEquals($_SERVER['DOCUMENT_ROOT'], Env::Server('DOCUMENT_ROOT'));
$this->assertSame($_SERVER, Env::Server());
$this->assertSame($_SERVER['DOCUMENT_ROOT'], Env::Server('DOCUMENT_ROOT'));
$this->assertNotEmpty(Env::Server());
$this->assertArrayHasKey('DOCUMENT_ROOT', Env::Server());
}
@ -63,52 +63,52 @@ class EnvTest extends PHPUnit_Framework_TestCase
{
$this->assertTrue(Env::setCookie('var', 'value', 20));
$_COOKIE['var'] = 'value';
$this->assertEquals(array('var' => 'value'), Env::Cookie());
$this->assertEquals('value', Env::Cookie('var'));
$this->assertEquals('default', Env::Cookie('new', 'default'));
$this->assertSame(array('var' => 'value'), Env::Cookie());
$this->assertSame('value', Env::Cookie('var'));
$this->assertSame('default', Env::Cookie('new', 'default'));
}
public function testPost()
{
$_POST['var'] = 'value';
$this->assertEquals(array('var' => 'value'), Env::Post());
$this->assertEquals('value', Env::Post('var'));
$this->assertEquals('default', Env::Post('new', 'default'));
$this->assertSame(array('var' => 'value'), Env::Post());
$this->assertSame('value', Env::Post('var'));
$this->assertSame('default', Env::Post('new', 'default'));
}
public function testGet()
{
$_GET['var'] = 'value';
$this->assertEquals(array('var' => 'value'), Env::Get());
$this->assertEquals('value', Env::Get('var'));
$this->assertEquals('default', Env::Get('new', 'default'));
$this->assertSame(array('var' => 'value'), Env::Get());
$this->assertSame('value', Env::Get('var'));
$this->assertSame('default', Env::Get('new', 'default'));
}
public function testFiles()
{
$this->assertEquals('default', Env::Files('file.txt', 'default'));
$this->assertEquals(array(), Env::Files());
$this->assertSame('default', Env::Files('file.txt', 'default'));
$this->assertSame(array(), Env::Files());
}
public function testUnsetFiles()
{
unset($_FILES);
$this->assertEquals('default', Env::Files('file.txt', 'default'));
$this->assertSame('default', Env::Files('file.txt', 'default'));
$_FILES['file'] = array('name' => 'files', 'path' => '/');
$this->assertEquals(array('name' => 'files', 'path' => '/'), Env::Files('file', 'default'));
$this->assertEquals('files', Env::Files('file', 'empty', 'name'));
$this->assertSame(array('name' => 'files', 'path' => '/'), Env::Files('file', 'default'));
$this->assertSame('files', Env::Files('file', 'empty', 'name'));
}
public function testParams()
{
Env::setParams(array('name' => 'tony', 'age' => 21));
$this->assertEquals(array('name' => 'tony', 'age' => 21), Env::getParam());
$this->assertSame(array('name' => 'tony', 'age' => 21), Env::getParam());
Env::setParams(array('sex' => 'male'));
$this->assertEquals(array('name' => 'tony', 'age' => 21, 'sex' => 'male'), Env::getParam());
$this->assertEquals('tony', Env::getParam('name'));
$this->assertEquals('default', Env::getParam('height', 'default'));
$this->assertSame(array('name' => 'tony', 'age' => 21, 'sex' => 'male'), Env::getParam());
$this->assertSame('tony', Env::getParam('name'));
$this->assertSame('default', Env::getParam('height', 'default'));
Env::setParam('surname', 'grebnev');
$this->assertEquals('grebnev', Env::getParam('surname'));
$this->assertSame('grebnev', Env::getParam('surname'));
}
public function tearDown()

74
tests/classes/FormatTest.php

@ -20,9 +20,9 @@ class FormatTest extends PHPUnit_Framework_TestCase
public function testCurrency()
{
$this->assertEquals('руб.', Format::getCurrency());
$this->assertSame('руб.', Format::getCurrency());
Format::setCurrencySymbol('usd');
$this->assertEquals('usd', Format::getCurrency());
$this->assertSame('usd', Format::getCurrency());
}
/**
@ -36,40 +36,40 @@ class FormatTest extends PHPUnit_Framework_TestCase
//$this->printStr($a);
//$this->printStr($b);
$this->assertEquals('2' . chr(0xC2) . chr(0xA0) . '000&nbsp;руб.', Format::int2money(200000, true, false));
$this->assertEquals('20 000,00', Format::int2money(2000000, false));
$this->assertSame('2' . chr(0xC2) . chr(0xA0) . '000&nbsp;руб.', Format::int2money(200000, true, false));
$this->assertSame('20 000,00', Format::int2money(2000000, false));
Format::setCurrencySymbol('usd');
$this->assertEquals('200,00&nbsp;usd', Format::int2money(20000, true));
$this->assertSame('200,00&nbsp;usd', Format::int2money(20000, true));
}
public function testMoney2Int()
{
$this->assertEquals(20000, Format::money2int('200,00', false));
$this->assertEquals(20000, Format::money2int('200', false));
$this->assertEquals(2000, Format::money2int('2 000руб.'));
$this->assertSame(20000, Format::money2int('200,00', false));
$this->assertSame(20000, Format::money2int('200', false));
$this->assertSame(2000, Format::money2int('2 000руб.'));
}
public function testInt2Time()
{
$time = 14 * 60 * 60 + 44 * 60 + 24;
$this->assertEquals('14:44:24', Format::int2time($time));
$this->assertEquals('00:00:00', Format::int2time());
$this->assertSame('14:44:24', Format::int2time($time));
$this->assertSame('00:00:00', Format::int2time());
}
public function testInt2Date()
{
$this->assertEquals(date('H:i d.m.Y', 0), Format::int2date());
$this->assertEquals(date('H:i d.m.Y'), Format::int2date(time()));
$this->assertEquals(date('d.m.Y'), Format::int2date(time(), false));
$this->assertEquals('20.04.2011', Format::int2date(strtotime('20 April 2011'), false));
$this->assertEquals('21:10 20.04.2011', Format::int2date(strtotime('21:10:30 20 April 2011')));
$this->assertSame(date('H:i d.m.Y', 0), Format::int2date());
$this->assertSame(date('H:i d.m.Y'), Format::int2date(time()));
$this->assertSame(date('d.m.Y'), Format::int2date(time(), false));
$this->assertSame('20.04.2011', Format::int2date(strtotime('20 April 2011'), false));
$this->assertSame('21:10 20.04.2011', Format::int2date(strtotime('21:10:30 20 April 2011')));
}
public function testInt2rusDate()
{
$this->assertEquals('10 января 1990', Format::int2rusDate(strtotime('10 January 1990')));
$this->assertEquals('19:10 10 января 1990', Format::int2rusDate(strtotime('19:10:59 10 January 1990'), true));
$this->assertSame('10 января 1990', Format::int2rusDate(strtotime('10 January 1990')));
$this->assertSame('19:10 10 января 1990', Format::int2rusDate(strtotime('19:10:59 10 January 1990'), true));
}
public function testSetTimezoneOffset()
@ -78,43 +78,43 @@ class FormatTest extends PHPUnit_Framework_TestCase
$class = new ReflectionClass('Format');
$offset = $class->getProperty('timezone_offset');
$offset->setAccessible(true);
$this->assertEquals(3, $offset->getValue());
$this->assertSame(3, $offset->getValue());
}
public function testSetDateTimeFormat()
{
Format::setDateFormat('H_i d::m::Y', 'd--m--Y');
$this->assertEquals('14_22 20::04::2011', Format::int2date(strtotime('14:22:00 20 April 2011')));
$this->assertEquals('20--04--2011', Format::int2date(strtotime('14:22:00 20 April 2011'), false));
$this->assertSame('14_22 20::04::2011', Format::int2date(strtotime('14:22:00 20 April 2011')));
$this->assertSame('20--04--2011', Format::int2date(strtotime('14:22:00 20 April 2011'), false));
}
public function testSetTodayFormat()
{
Format::setTodayFormat('H_i d::m::Y', 'd--m--Y');
$this->assertEquals(date('H_i d::m::Y', strtotime('+2hours' )), Format::int2date(strtotime('+2 hours')));
$this->assertEquals(date('d--m--Y', strtotime('+2hours' )), Format::int2date(strtotime('+2 hours'), false));
$this->assertSame(date('H_i d::m::Y', strtotime('+2hours' )), Format::int2date(strtotime('+2 hours')));
$this->assertSame(date('d--m--Y', strtotime('+2hours' )), Format::int2date(strtotime('+2 hours'), false));
}
public function testTime2Int()
{
$time = 14 * 60 * 60 + 44 * 60 + 24;
$this->assertEquals($time, Format::time2int('14:44:24'));
$this->assertEquals(14, Format::time2int('14:44'));
$this->assertEquals(14, Format::time2int('14:44:32:53:12'));
$this->assertSame($time, Format::time2int('14:44:24'));
$this->assertSame(14, Format::time2int('14:44'));
$this->assertSame(14, Format::time2int('14:44:32:53:12'));
}
public function testDate2Int()
{
$this->assertEquals(strtotime('2 Jan 2010'), Format::date2int('2 Jan 2010'));
$this->assertSame(strtotime('2 Jan 2010'), Format::date2int('2 Jan 2010'));
}
public function testInt2Phone()
{
$this->assertEquals('777-77-77', Format::int2phone(7777777));
$this->assertEquals('(123) 456-78-90', Format::int2phone(1234567890));
$this->assertEquals('', Format::int2phone(12890));
$this->assertEquals('', Format::int2phone('asdas'));
$this->assertSame('777-77-77', Format::int2phone(7777777));
$this->assertSame('(123) 456-78-90', Format::int2phone(1234567890));
$this->assertSame('', Format::int2phone(12890));
$this->assertSame('', Format::int2phone('asdas'));
}
/**
@ -122,21 +122,21 @@ class FormatTest extends PHPUnit_Framework_TestCase
*/
public function testPhone2Int()
{
$this->assertEquals('4951234567', Format::phone2int('123-45-67'));
$this->assertEquals('9261234567', Format::phone2int('926-123-45-67'));
$this->assertEquals('', Format::phone2int('8-926-123-45-67'));
$this->assertEquals('', Format::phone2int('12-45-67'));
$this->assertEquals('', Format::phone2int('not a phone'));
$this->assertSame('4951234567', Format::phone2int('123-45-67'));
$this->assertSame('9261234567', Format::phone2int('926-123-45-67'));
$this->assertSame('', Format::phone2int('8-926-123-45-67'));
$this->assertSame('', Format::phone2int('12-45-67'));
$this->assertSame('', Format::phone2int('not a phone'));
}
public function testBytes2MB()
{
$this->assertEquals('1МБ', Format::bytes2MB(1048576));
$this->assertSame('1МБ', Format::bytes2MB(1048576));
}
public function testBytes2KB()
{
$this->assertEquals('2КБ', Format::bytes2KB(2048));
$this->assertSame('2КБ', Format::bytes2KB(2048));
}

8
tests/exception/ErrorHandlerTest.php

@ -30,7 +30,7 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase
ErrorHandler::init();
$eh = set_error_handler($my_eh);
$this->assertInternalType('array', $eh);
$this->assertEquals($eh, $my_eh);
$this->assertSame($eh, $my_eh);
}
public function testHandleError()
@ -65,11 +65,11 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase
$method = $class->getMethod('WrapTrace');
$method->setAccessible(true);
$result = $method->invoke(null, "first line\nsecond line");
$this->assertEquals("<code>first line<br />\nsecond line</code>", $result);
$this->assertSame("<code>first line<br />\nsecond line</code>", $result);
$result = $method->invoke(null, "first line\r\nsecond line");
$this->assertEquals("<code>first line<br />\r\nsecond line</code>", $result);
$this->assertSame("<code>first line<br />\r\nsecond line</code>", $result);
$result = $method->invoke(null, "first line\r\n\r\nsecond line");
$this->assertEquals("<code>first line<br />\r\n<br />\r\nsecond line</code>", $result);
$this->assertSame("<code>first line<br />\r\n<br />\r\nsecond line</code>", $result);
}
public function tearDown()

4
tests/form/FormFieldTest.php

@ -175,7 +175,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
$this->assertTrue($form_field->isValid($test_string));
$this->assertAttributeNotInternalType('array', 'value', $form_field);
$this->assertEquals('login', $form_field->getValue());
$this->assertSame('login', $form_field->getValue());
}
public function testGetValueStringIncorrect()
@ -186,7 +186,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
$this->assertTrue($form_field->isValid($test_string));
$this->assertAttributeNotInternalType('array', 'value', $form_field);
$this->assertEquals('', $form_field->getValue());
$this->assertSame('', $form_field->getValue());
}
public function testGetMessageDefault()

4
tests/form/FormTest.php

@ -31,7 +31,7 @@ class FormTest extends PHPUnit_Framework_TestCase
$return_object = $method->invokeArgs($stub, array('login'));
$this->assertInstanceOf('FormField', $return_object);
$this->assertEquals($form_field, $return_object);
$this->assertSame($form_field, $return_object);
}
public function testAddFieldWithMessage()
@ -44,7 +44,7 @@ class FormTest extends PHPUnit_Framework_TestCase
$return_object = $method->invokeArgs($stub, array('login', $message));
$this->assertInstanceOf('FormField', $return_object);
$this->assertEquals($form_field, $return_object);
$this->assertSame($form_field, $return_object);
$this->assertAttributeEquals($message, 'default_message', $return_object);
}

8
tests/i18n/I18NTest.php

@ -144,8 +144,8 @@ class I18NTest extends PHPUnit_Framework_TestCase
Config::set('I18N', array('locales' => array('en' => 'en_US'), 'default' => 'ru'));
I18N::init();
$this->assertEquals('en', I18N::getLang());
$this->assertEquals('ru', I18N::getDefaultLang());
$this->assertSame('en', I18N::getLang());
$this->assertSame('ru', I18N::getDefaultLang());
}
/**
@ -159,7 +159,7 @@ class I18NTest extends PHPUnit_Framework_TestCase
Config::set('I18N', array('locales' => array('ru' => 'ru-ru'), 'default' => 'ru'));
I18N::init();
I18N::setLangs(array('en' => 'en-us', 'fr' => 'fr-fr'));
$this->assertEquals(array('en' => 'en-us', 'fr' => 'fr-fr'), I18N::getLangs());
$this->assertSame(array('en' => 'en-us', 'fr' => 'fr-fr'), I18N::getLangs());
}
/**
@ -173,7 +173,7 @@ class I18NTest extends PHPUnit_Framework_TestCase
Config::set('I18N', array('locales' => array('ru' => 'ru-ru'), 'default' => 'ru'));
I18N::init();
I18N::setLangs(array('ru' => 'ru_ru', 'en' => 'en-us', 'fr' => 'fr-fr'));
$this->assertEquals('ru_ru', I18N::getLangName());
$this->assertSame('ru_ru', I18N::getLangName());
$this->assertFalse(I18N::getLangName('br'));
}

2
tests/logger/FileLoggerTest.php

@ -103,7 +103,7 @@ class FileLoggerTest extends PHPUnit_Framework_TestCase
$logger->__destruct();
$this->assertAttributeEquals(null, 'handler', $logger);
$fd_count_end = (int) `$fd_command`;
$this->assertEquals($fd_count_start, $fd_count_end);
$this->assertSame($fd_count_start, $fd_count_end);
}
public function tearDown()

24
tests/model/DbDriverTest.php

@ -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()

2
tests/model/DbExprTest.php

@ -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);
}
}

14
tests/model/DbStatementTest.php

@ -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)

18
tests/model/ModelTest.php

@ -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()

24
tests/model/MySQLiDriverTest.php

@ -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()

14
tests/model/MySQLiStatementTest.php

@ -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()

22
tests/session/SessionTest.php

@ -43,8 +43,8 @@ class SessionTest extends PHPUnit_Framework_TestCase
Session::set('one', 1);
Session::set('two', 'three');
Session::set(array('first' => '1st', 'second' => '2nd'));
$this->assertEquals('1st', Session::get('first'));
$this->assertEquals('three', Session::get('two'));
$this->assertSame('1st', Session::get('first'));
$this->assertSame('three', Session::get('two'));
$this->assertNotEquals('three', Session::get('thr'));
}
@ -58,21 +58,21 @@ class SessionTest extends PHPUnit_Framework_TestCase
public function testReturnDefaultValue()
{
Session::start();
$this->assertEquals(1, Session::get('key', 1));
$this->assertSame(1, Session::get('key', 1));
}
public function testDestroyedGet()
{
$this->assertFalse($this->started->getValue());
$_COOKIE[session_name()] = session_name();
$this->assertEquals(1, Session::get('key', 1));
$this->assertSame(1, Session::get('key', 1));
}
public function testDel()
{
Session::set('one', 1);
Session::set('two', 'three');
$this->assertEquals('three', Session::get('two'));
$this->assertSame('three', Session::get('two'));
Session::del('two');
$this->assertNull(Session::get('two'));
}
@ -109,10 +109,10 @@ class SessionTest extends PHPUnit_Framework_TestCase
$new_params = session_get_cookie_params();
$this->assertNotEquals($ssid, $new_ssid);
$this->assertNotEquals($params, $new_params);
$this->assertEquals(400, $new_params['lifetime']);
$this->assertSame(400, $new_params['lifetime']);
Session::rememberUntil();
$new_params = session_get_cookie_params();
$this->assertEquals(0, $new_params['lifetime']);
$this->assertSame(0, $new_params['lifetime']);
}
public function testForget()
@ -123,7 +123,7 @@ class SessionTest extends PHPUnit_Framework_TestCase
$new_ssid = Session::getId();
$new_params = session_get_cookie_params();
$this->assertNotEquals($ssid, $new_ssid);
$this->assertEquals(0, $new_params['lifetime']);
$this->assertSame(0, $new_params['lifetime']);
}
public function testRemember()
@ -132,15 +132,15 @@ class SessionTest extends PHPUnit_Framework_TestCase
$ssid = Session::getId();
Session::remember();
$new_params = session_get_cookie_params();
$this->assertEquals(1209600, $new_params['lifetime']);
$this->assertSame(1209600, $new_params['lifetime']);
Session::remember(-30);
$new_params = session_get_cookie_params();
$this->assertEquals(1209600, $new_params['lifetime']);
$this->assertSame(1209600, $new_params['lifetime']);
Session::remember(530);
$new_params = session_get_cookie_params();
$this->assertEquals(530, $new_params['lifetime']);
$this->assertSame(530, $new_params['lifetime']);
}
public function testExpireSessionCookie()

2
tests/util/AutoloadBuilderTestVFS.php

@ -97,7 +97,7 @@ class AutoloadBuilderTestVFS extends PHPUnit_Framework_TestCase
$this->assertInternalType('array', $this->array);
$this->assertArrayHasKey('Load', $this->array);
$this->assertArrayNotHasKey('Key', $this->array);
$this->assertEquals(2, count($this->array));
$this->assertSame(2, count($this->array));
}
public function testAutoloadHasNoAccess()

4
tests/util/profiler/CommandProfilerTest.php

@ -30,13 +30,13 @@ class CommandProfilerTest extends PHPUnit_Framework_TestCase
public function testGetType()
{
$this->assertEquals('method', $this->profiler->getType());
$this->assertSame('method', $this->profiler->getType());
$this->assertNotEquals('argument', $this->profiler->getType());
}
public function testGetCommand()
{
$this->assertEquals('exec', $this->profiler->getCommand());
$this->assertSame('exec', $this->profiler->getCommand());
$this->assertNotEquals('grep', $this->profiler->getCommand());
}
}

2
tests/util/profiler/ProfilerTest.php

@ -87,7 +87,7 @@ class ProfilerTest extends PHPUnit_Framework_TestCase
$this->assertContains('<div style="clear:both; font:12px monospace; margin: 5px; white-space: pre;">', $result);
$this->assertEquals('html', $profiler->end('html'));
$this->assertSame('html', $profiler->end('html'));
}
/**

2
tests/validator/RegexValidatorTest.php

@ -42,7 +42,7 @@ class RegexValidatorTest extends PHPUnit_Framework_TestCase
$this->assertEmpty($validator->getMessage());
$validator->setMessage('i am ok');
$validator->isValid('2131');
$this->assertEquals('i am ok', $validator->getMessage());
$this->assertSame('i am ok', $validator->getMessage());
}

4
tests/view/PHPViewTest.php

@ -42,7 +42,7 @@ class PHPViewTest extends PHPUnit_Framework_TestCase
public function testPHPViewConstructor()
{
$this->assertInstanceOf('PHPView', $this->view);
$this->assertEquals('vfs://root/views/', $this->view->getPath());
$this->assertSame('vfs://root/views/', $this->view->getPath());
}
@ -75,7 +75,7 @@ class PHPViewTest extends PHPUnit_Framework_TestCase
public function testEscape()
{
$result = $this->view->escape('"<>"');
$this->assertEquals('&quot;&lt;&gt;&quot;', $result);
$this->assertSame('&quot;&lt;&gt;&quot;', $result);
}
public function testCall()

8
tests/view/helpers/GetViewHelperTest.php

@ -48,16 +48,16 @@ class GetViewHelperTest extends PHPUnit_Framework_TestCase
{
$_GET['a'] = 'b';
$result = $this->helper->get(null);
$this->assertEquals('?a=b', $result);
$this->assertSame('?a=b', $result);
$this->helper = new GetViewHelper(new PHPView('any'));
$_GET['a'] = 'b';
$_GET['b'] = 'a';
$result = $this->helper->get(array('a' => 'c'));
$this->assertEquals('?a=c&amp;b=a', $result);
$this->assertSame('?a=c&amp;b=a', $result);
$_GET['a'] = 'b';
$_GET['b'] = 'a';
$result = $this->helper->get(array('a'));
$this->assertEquals('?b=a', $result);
$this->assertSame('?b=a', $result);
}
public function testGetWithArray()
@ -66,7 +66,7 @@ class GetViewHelperTest extends PHPUnit_Framework_TestCase
$_GET['b'] = 'a';
$_GET['c'] = array('three' => 'four');
$result = $this->helper->get(array('b' => 'c', 'c' => array('five' => 'six')));
$this->assertEquals('?a[one]=1&amp;a[two]=2&amp;b=c&amp;c[five]=six', $result);
$this->assertSame('?a[one]=1&amp;a[two]=2&amp;b=c&amp;c[five]=six', $result);
}
}
Loading…
Cancel
Save