Replacement of assertEquals() to assertSame()

This commit is contained in:
Vyacheslav Agafonov
2011-12-02 17:22:31 +04:00
parent 3a79d203c7
commit 0fdcb87653
35 changed files with 214 additions and 214 deletions

View File

@ -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']);
}
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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