public function test_normalize() { $tagset = array('Cat', ' Dog ', '<Mouse', '<>', 'mouse', 'Dog'); // Test function tag_normalize() that was deprecated in 3.1. $this->assertEquals(array('Cat' => 'Cat', 'Dog' => 'Dog', '<Mouse' => 'Mouse', '<>' => '', 'mouse' => 'mouse'), tag_normalize($tagset, TAG_CASE_ORIGINAL)); $this->assertDebuggingCalled(); $this->assertEquals(array('Cat' => 'cat', 'Dog' => 'dog', '<Mouse' => 'mouse', '<>' => '', 'mouse' => 'mouse'), tag_normalize($tagset, TAG_CASE_LOWER)); $this->assertDebuggingCalled(); // Test replacement function core_tag_tag::normalize(). $this->assertEquals(array('Cat' => 'Cat', 'Dog' => 'Dog', '<Mouse' => 'Mouse', '<>' => '', 'mouse' => 'mouse'), core_tag_tag::normalize($tagset, false)); $this->assertEquals(array('Cat' => 'cat', 'Dog' => 'dog', '<Mouse' => 'mouse', '<>' => '', 'mouse' => 'mouse'), core_tag_tag::normalize($tagset, true)); }
/** * Function that normalizes a list of tag names. * * @package core_tag * @deprecated since 3.1 * @param array/string $rawtags array of tags, or a single tag. * @param int $case case to use for returned value (default: lower case). Either TAG_CASE_LOWER (default) or TAG_CASE_ORIGINAL * @return array lowercased normalized tags, indexed by the normalized tag, in the same order as the original array. * (Eg: 'Banana' => 'banana'). */ function tag_normalize($rawtags, $case = TAG_CASE_LOWER) { debugging('Function tag_normalize() is deprecated. Use core_tag_tag::normalize().', DEBUG_DEVELOPER); if (!is_array($rawtags)) { $rawtags = array($rawtags); } return core_tag_tag::normalize($rawtags, $case == TAG_CASE_LOWER); }