Cleaned up longhand arrays, added Profanity tests

This commit is contained in:
Joshua Sherman 2014-01-03 17:52:24 -05:00
parent 5678e75fbd
commit ff44cd0e17
6 changed files with 100 additions and 73 deletions

View file

@ -0,0 +1,29 @@
<?php
class API_Google_ProfanityTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerFormatPhoneNumber
*/
public function testCheck($a, $b)
{
$this->assertEquals($b, API_Google_Profanity::check($a));
}
public function providerFormatPhoneNumber()
{
return [
['alpha', false],
['beta', false],
['joshtronic', false],
['god', false],
['fck', false],
['fuck', true],
['shit', true],
['cocksucker', true],
['cuntface', false], // Unsure why not...
];
}
}
?>

View file

@ -12,14 +12,14 @@ class ConvertTest extends PHPUnit_Framework_TestCase
public function providerArrayToXML()
{
return array(
array('foo', false, ''),
array(array('foo', 'bar'), false, '<0>foo</0><1>bar</1>'),
array(array('foo', 'bar'), true, "<0>foo</0>\n<1>bar</1>\n"),
array(array('foo' => 'bar'), false, '<foo>bar</foo>'),
array(array('children' => array('child' => array('foo', 'bar'))), false, '<children><child>foo</child><child>bar</child></children>'),
array(array('children' => array('child' => array('foo', 'bar'))), true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"),
);
return [
['foo', false, ''],
[['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>'],
[['children' => ['child' => ['foo', 'bar']]], false, '<children><child>foo</child><child>bar</child></children>'],
[['children' => ['child' => ['foo', 'bar']]], true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"],
];
}
}

View file

@ -16,14 +16,14 @@ class DateTest extends PHPUnit_Framework_TestCase
$time = strtotime('-25 years');
return array(
array(date('Y-m-d', $time), '25'),
array(date('m/d/Y', $time), '25'),
array(date('r', $time), '25'),
array('today', '0'),
array('400 days ago', '1'),
array(true, Date::age('1969-12-31')),
);
return [
[date('Y-m-d', $time), '25'],
[date('m/d/Y', $time), '25'],
[date('r', $time), '25'],
['today', '0'],
['400 days ago', '1'],
[true, Date::age('1969-12-31')],
];
}
}

View file

@ -12,16 +12,16 @@ class NumberTest extends PHPUnit_Framework_TestCase
public function providerOrginalIndicatorNoSuper()
{
return array(
array(1, '1st'),
array(2, '2nd'),
array(3, '3rd'),
array(4, '4th'),
array(51, '51st'),
array(52, '52nd'),
array(53, '53rd'),
array(54, '54th'),
);
return [
[1, '1st'],
[2, '2nd'],
[3, '3rd'],
[4, '4th'],
[51, '51st'],
[52, '52nd'],
[53, '53rd'],
[54, '54th'],
];
}
/**
@ -34,16 +34,16 @@ class NumberTest extends PHPUnit_Framework_TestCase
public function providerOrginalIndicatorSuper()
{
return array(
array(1, '1<sup>st</sup>'),
array(2, '2<sup>nd</sup>'),
array(3, '3<sup>rd</sup>'),
array(4, '4<sup>th</sup>'),
array(51, '51<sup>st</sup>'),
array(52, '52<sup>nd</sup>'),
array(53, '53<sup>rd</sup>'),
array(54, '54<sup>th</sup>'),
);
return [
[1, '1<sup>st</sup>'],
[2, '2<sup>nd</sup>'],
[3, '3<sup>rd</sup>'],
[4, '4<sup>th</sup>'],
[51, '51<sup>st</sup>'],
[52, '52<sup>nd</sup>'],
[53, '53<sup>rd</sup>'],
[54, '54<sup>th</sup>'],
];
}
}

View file

@ -12,17 +12,17 @@ class StringTest extends PHPUnit_Framework_TestCase
public function providerFormatPhoneNumber()
{
return array(
array('1234567890', '123-456-7890'),
array('123 456 7890', '123-456-7890'),
array('123.456.7890', '123-456-7890'),
array('123_456_7890', '123-456-7890'),
array('1234567890', '123-456-7890'),
array('1234-56-7890', '123-456-7890'),
array('(123) 456-7890', '123-456-7890'),
array('1234567890 x1000', '123-456-7890x1000'),
array('(123) 456-7890_x10.00', '123-456-7890x1000'),
);
return [
['1234567890', '123-456-7890'],
['123 456 7890', '123-456-7890'],
['123.456.7890', '123-456-7890'],
['123_456_7890', '123-456-7890'],
['1234567890', '123-456-7890'],
['1234-56-7890', '123-456-7890'],
['(123) 456-7890', '123-456-7890'],
['1234567890 x1000', '123-456-7890x1000'],
['(123) 456-7890_x10.00', '123-456-7890x1000'],
];
}
/**
@ -35,10 +35,10 @@ class StringTest extends PHPUnit_Framework_TestCase
public function providerGenerateGravatarHash()
{
return array(
array('foo@bar.com', 'f3ada405ce890b6f8204094deb12d8a8'),
array('FOO@BAR.COM', 'f3ada405ce890b6f8204094deb12d8a8'),
);
return [
['foo@bar.com', 'f3ada405ce890b6f8204094deb12d8a8'],
['FOO@BAR.COM', 'f3ada405ce890b6f8204094deb12d8a8'],
];
}
public function testIsEmpty()
@ -79,12 +79,12 @@ class StringTest extends PHPUnit_Framework_TestCase
public function providerTruncate()
{
return array(
array('foo bar', 3, true, '<span title="foo bar">foo&hellip;</span>'),
array('foo bar', 3, false, 'foo...'),
array('foo bar', 7, true, 'foo bar'),
array('foo bar', 8, true, 'foo bar'),
);
return [
['foo bar', 3, true, '<span title="foo bar">foo&hellip;</span>'],
['foo bar', 3, false, 'foo...'],
['foo bar', 7, true, 'foo bar'],
['foo bar', 8, true, 'foo bar'],
];
}
/**
@ -97,13 +97,13 @@ class StringTest extends PHPUnit_Framework_TestCase
public function providerUpperWords()
{
return array(
array('foo bar', 'Foo Bar'),
array('FOO BAR', 'Foo Bar'),
array('fOO bAR', 'Foo Bar'),
array('foo@bar.com', 'foo@bar.com'),
array('FOO@BAR.COM', 'FOO@BAR.COM'),
);
return [
['foo bar', 'Foo Bar'],
['FOO BAR', 'Foo Bar'],
['fOO bAR', 'Foo Bar'],
['foo@bar.com', 'foo@bar.com'],
['FOO@BAR.COM', 'FOO@BAR.COM'],
];
}
/**
@ -116,13 +116,13 @@ class StringTest extends PHPUnit_Framework_TestCase
public function providerGenerateSlug()
{
return array(
array('TEST STRING', 'test-string'),
array('Test String', 'test-string'),
array('TEST STRING', 'test-string'),
array('#! Test String', 'test-string'),
array('-test--string-', 'test-string'),
);
return [
['TEST STRING', 'test-string'],
['Test String', 'test-string'],
['TEST STRING', 'test-string'],
['#! Test String', 'test-string'],
['-test--string-', 'test-string'],
];
}
public function testPluralize()