Replacement of assertEquals() to assertSame()
This commit is contained in:
@ -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