Merge branch 'master' of github.com:joshtronic/pickles

This commit is contained in:
Josh Sherman 2014-05-10 12:52:28 -04:00
commit 5349159c51
39 changed files with 498 additions and 209 deletions

View file

@ -28,7 +28,7 @@ class API_AYAHTest extends PHPUnit_Framework_TestCase
'scoring_key' => '80cc3f9c6e1da29369c238d55bd8528a968473ad',
];
$this->assertRegExp('/<div id=\'AYAH\'><\/div><script src=\'https:\/\/ws.areyouahuman.com\/ws\/script\/[a-z0-9]{40}\/ip[a-zA-Z0-9]{43}\' type=\'text\/javascript\' language=\'JavaScript\'><\/script>/', API_AYAH::getHTML());
$this->assertRegExp('/<div id=\'AYAH\'><\/div><script src=\'https:\/\/ws.areyouahuman.com\/ws\/script\/[a-z0-9]{40}\/[a-zA-Z0-9]{45}\' type=\'text\/javascript\' language=\'JavaScript\'><\/script>/', API_AYAH::getHTML());
}
public function testIsNotHuman()

View file

@ -0,0 +1,68 @@
<?php
class API_PlaceholdIt_Test extends PHPUnit_Framework_TestCase
{
private $placeholdit;
public function setUp()
{
$this->placeholdit = new API_PlaceholdIt();
}
public function testInstantiateObject()
{
$this->assertInstanceOf('API_PlaceholdIt', $this->placeholdit);
}
public function testURL()
{
$expected = 'http://placehold.it/350x150.png/ffffff/000000&text=PICKLES+Rules%21';
$url = $this->placeholdit->url(350, 150, 'png', 'ffffff', '000000', 'PICKLES Rules!');
$this->assertEquals($expected, $url);
}
/**
* @expectedException Exception
* @expectedExceptionMessage Invalid format. Valid formats: gif, jpeg, jpg and png.
*/
public function testInvalidFormat()
{
$this->placeholdit->url(350, 150, 'invalid');
}
/**
* @expectedException Exception
* @expectedExceptionMessage You must specify a background color if you wish to specify a foreground color.
*/
public function testForegroundNoBackground()
{
$this->placeholdit->url(350, 150, 'png', false, '000000');
}
/**
* @expectedException Exception
* @expectedExceptionMessage The background color must be a 6 character hex code.
*/
public function testInvalidBackground()
{
$this->placeholdit->url(350, 150, 'png', 'fff');
}
/**
* @expectedException Exception
* @expectedExceptionMessage The foreground color must be a 6 character hex code.
*/
public function testInvalidForeground()
{
$this->placeholdit->url(350, 150, 'png', 'ffffff', '000');
}
public function testIMG()
{
$expected = '<img src="http://placehold.it/350x150.png/ffffff/000000&text=PICKLES+Rules%21">';
$url = $this->placeholdit->img(350, 150, 'png', 'ffffff', '000000', 'PICKLES Rules!');
$this->assertEquals($expected, $url);
}
}
?>

View file

@ -86,7 +86,7 @@ class StringTest extends PHPUnit_Framework_TestCase
{
return [
['foo bar', 3, true, '<span title="foo bar">foo&hellip;</span>'],
['foo bar', 3, false, 'foo...'],
['foo bar', 3, false, 'foo&hellip;'],
['foo bar', 7, true, 'foo bar'],
['foo bar', 8, true, 'foo bar'],
];

View file

@ -32,41 +32,64 @@ class TimeTest extends PHPUnit_Framework_TestCase
$this->assertEquals('seconds ago', Time::ago(strtotime('-30 seconds')));
}
public function testAgoPastTimeMinute()
{
$this->assertEquals('a minute ago', Time::ago(strtotime('-1 minutes')));
}
public function testAgoPastTimeMinutes()
{
$this->assertEquals('5 minutes ago', Time::ago(strtotime('-5 minutes')));
}
public function testAgoPastTimeHour()
{
$this->assertEquals('an hour ago', Time::ago(strtotime('-1 hours')));
}
public function testAgoPastTimeHours()
{
$this->assertEquals('1 hour ago', Time::ago(strtotime('-1 hour')));
$this->assertEquals('2 hours ago', Time::ago(strtotime('-2 hours')));
}
public function testAgoPastTimeDay()
{
$this->assertEquals('a day ago', Time::ago(strtotime('-1 days')));
}
public function testAgoPastTimeDays()
{
$this->assertEquals('1 day ago', Time::ago(strtotime('-1 day')));
$this->assertEquals('2 days ago', Time::ago(strtotime('-2 days')));
}
/* @todo Need to fix these results so it doesn't fail.
public function testAgoPastTimeDays2()
public function testAgoPastTimeWeek()
{
$this->assertEquals('1 day ago', Time::ago(strtotime('-23 hours -55 minutes')));
$this->assertEquals('a week ago', Time::ago(strtotime('-1 weeks')));
}
*/
public function testAgoPastTimeWeeks()
{
$this->assertEquals('1 week ago', Time::ago(strtotime('-1 week')));
$this->assertEquals('2 weeks ago', Time::ago(strtotime('-2 weeks')));
}
public function testAgoPastTimeMonth()
{
$this->assertEquals('a month ago', Time::ago(strtotime('-1 months')));
}
public function testAgoPastTimeMonths()
{
$this->assertEquals('1 month ago', Time::ago(strtotime('-1 month')));
$this->assertEquals('2 months ago', Time::ago(strtotime('-2 months')));
}
public function testAgoPastTimeYear()
{
$this->assertEquals('a year ago', Time::ago(strtotime('-1 years')));
}
public function testAgoPastTimeYears()
{
$this->assertEquals('1 year ago', Time::ago(strtotime('-1 year')));
$this->assertEquals('2 years ago', Time::ago(strtotime('-2 years')));
}
public function testAgoFutureTimeSeconds()
@ -81,33 +104,58 @@ class TimeTest extends PHPUnit_Framework_TestCase
public function testAgoFutureTimeHours()
{
$this->assertEquals('1 hour from now', Time::ago(strtotime('+1 hour')));
$this->assertEquals('an hour from now', Time::ago(strtotime('+1 hour')));
}
public function testAgoFutureTimeDays()
{
$this->assertEquals('1 day from now', Time::ago(strtotime('+1 day')));
$this->assertEquals('a day from now', Time::ago(strtotime('+1 day')));
}
public function testAgoFutureTimeWeeks()
{
$this->assertEquals('1 week from now', Time::ago(strtotime('+1 week')));
$this->assertEquals('a week from now', Time::ago(strtotime('+1 week')));
}
public function testAgoFutureTimeMonths()
{
$this->assertEquals('1 month from now', Time::ago(strtotime('+1 month')));
$this->assertEquals('a month from now', Time::ago(strtotime('+1 month')));
}
public function testAgoFutureTimeYears()
{
$this->assertEquals('1 year from now', Time::ago(strtotime('+1 year')));
$this->assertEquals('a year from now', Time::ago(strtotime('+1 year')));
}
public function testTimestamp()
{
$this->assertEquals(gmdate('Y-m-d H:i:s'), Time::timestamp());
}
public function testRoundUpHour()
{
$this->assertEquals('an hour ago', Time::ago(strtotime('-59 minutes -55 seconds')));
}
public function testRoundUpDay()
{
$this->assertEquals('a day ago', Time::ago(strtotime('-23 hours -55 minutes')));
}
public function testRoundUpWeek()
{
$this->assertEquals('a week ago', Time::ago(strtotime('-6 days -23 hours')));
}
public function testRoundUpMonth()
{
$this->assertEquals('a month ago', Time::ago(strtotime('-29 days')));
}
public function testRoundUpYear()
{
$this->assertEquals('a year ago', Time::ago(strtotime('-364 days')));
}
}
?>