X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FUtilsTest.php;h=c885f552350b62cf003921c5b36673b3224eea14;hb=cc30d749ab17be2bf0b623a16f8fa78ecfd5b57d;hp=6a7870c4620ac5cd3bbf2a838f108c27755dd411;hpb=9ccca40189652e529732683abcdf54fcf775c9ec;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 6a7870c4..c885f552 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -253,4 +253,33 @@ class UtilsTest extends PHPUnit_Framework_TestCase is_session_id_valid('c0ZqcWF3VFE2NmJBdm1HMVQ0ZHJ3UmZPbTFsNGhkNHI=') ); } + + /** + * Test generateSecretApi. + */ + public function testGenerateSecretApi() + { + $this->assertEquals(12, strlen(generate_api_secret('foo', 'bar'))); + } + + /** + * Test generateSecretApi with invalid parameters. + */ + public function testGenerateSecretApiInvalid() + { + $this->assertFalse(generate_api_secret('', '')); + $this->assertFalse(generate_api_secret(false, false)); + } + + /** + * Test normalize_spaces. + */ + public function testNormalizeSpace() + { + $str = ' foo bar is important '; + $this->assertEquals('foo bar is important', normalize_spaces($str)); + $this->assertEquals('foo', normalize_spaces('foo')); + $this->assertEquals('', normalize_spaces('')); + $this->assertEquals(null, normalize_spaces(null)); + } }