Getting coverage to 100% on these classes
Also found a bug in the Form class that would bork phone numbers with dashes in them. Even though the Form class is going to go away eventually I wanted to fix the issue.
This commit is contained in:
parent
5ef3b58f53
commit
faaefc1b82
6 changed files with 164 additions and 11 deletions
|
@ -17,7 +17,9 @@ class ConvertTest extends PHPUnit_Framework_TestCase
|
|||
[['foo', 'bar'], false, '<0>foo</0><1>bar</1>'],
|
||||
[['foo', 'bar'], true, "<0>foo</0>\n<1>bar</1>\n"],
|
||||
[['foo' => 'bar'], false, '<foo>bar</foo>'],
|
||||
[['foo' => 'b & r'], false, '<foo><![CDATA[b & r]]></foo>'],
|
||||
[['children' => ['child' => ['foo', 'bar']]], false, '<children><child>foo</child><child>bar</child></children>'],
|
||||
[['children' => ['child' => ['foo & bar']]], false, '<children><child><![CDATA[foo & bar]]></child></children>'],
|
||||
[['children' => ['child' => ['foo', 'bar']]], true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,14 +2,29 @@
|
|||
|
||||
class FileTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
// Using actual filesystem because you can't chdir with vfs://
|
||||
$directory = '/tmp/pickles-fs/filetest/test/test';
|
||||
|
||||
if (!file_exists($directory))
|
||||
{
|
||||
mkdir($directory, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
File::removeDirectory('/tmp/pickles-fs');
|
||||
}
|
||||
|
||||
public function testRemoveDirectory()
|
||||
{
|
||||
$directory = SITE_PATH . 'test/test/test/';
|
||||
$directory = '/tmp/pickles-fs/filetest/';
|
||||
|
||||
mkdir($directory, 0777, true);
|
||||
touch(SITE_PATH . 'test/ing');
|
||||
touch(SITE_PATH . 'test/test/ing');
|
||||
touch(SITE_PATH . 'test/test/test/ing');
|
||||
touch($directory . 'ing');
|
||||
touch($directory . 'test/ing');
|
||||
touch($directory . 'test/test/ing');
|
||||
|
||||
File::removeDirectory($directory);
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -69,6 +69,11 @@ class StringTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(preg_match('/[a-z0-9]/', String::random(32, false, false)), 0);
|
||||
}
|
||||
|
||||
public function testRandomSimilarFalse()
|
||||
{
|
||||
$this->assertRegExp('/[a-hj-np-z2-9]{8}/', String::random(8, true, true, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTruncate
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,16 @@ class TimeTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(-18, Time::age(date('Y-m-d', strtotime('18 years'))));
|
||||
}
|
||||
|
||||
public function testAgeWrongFormat()
|
||||
{
|
||||
$this->assertEquals(17, Time::age(date('Ymd', strtotime('December 31st -18 years'))));
|
||||
}
|
||||
|
||||
public function testAgoJustNow()
|
||||
{
|
||||
$this->assertEquals('just now', Time::ago(Time::timestamp()));
|
||||
}
|
||||
|
||||
public function testAgoPastTimeSeconds()
|
||||
{
|
||||
$this->assertEquals('seconds ago', Time::ago(strtotime('-30 seconds')));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue