Replacement of assertEquals() to assertSame()
This commit is contained in:
@ -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()
|
||||
|
@ -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 руб.', Format::int2money(200000, true, false));
|
||||
$this->assertEquals('20 000,00', Format::int2money(2000000, false));
|
||||
$this->assertSame('2' . chr(0xC2) . chr(0xA0) . '000 руб.', Format::int2money(200000, true, false));
|
||||
$this->assertSame('20 000,00', Format::int2money(2000000, false));
|
||||
Format::setCurrencySymbol('usd');
|
||||
$this->assertEquals('200,00 usd', Format::int2money(20000, true));
|
||||
$this->assertSame('200,00 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));
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user