Beispiel #1
0
 public function testTagNames()
 {
     $stub = $this->randomStub();
     $str = 'First Tag, Second Tag, Tag #3';
     $arr = array('First Tag', 'Second Tag', 'Tag #3');
     $this->assertSame($arr, TaggingUtil::makeTagArray($str));
     $stub->tag($str);
     $this->assertSame($arr, $stub->tagNames());
 }
Beispiel #2
0
 public function save(array $options = array())
 {
     $validator = \Validator::make(array('name' => $this->name), array('name' => 'required|min:1'));
     if ($validator->passes()) {
         $this->slug = TaggingUtil::slug($this->name);
         parent::save($options);
     } else {
         throw new \Exception('Tag Name is required');
     }
 }
Beispiel #3
0
 public function test_slug()
 {
     $this->assertEquals('sugar-free', TaggingUtil::slug('Sugar Free'));
     $str = 'ПЧ�Цщ';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
     $str = 'quiénsí';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
     $str = 'ČĢ';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
     $str = 'same-slug';
     $this->assertEquals(TaggingUtil::slug($str), $str);
     $str = '&=*!$&&,';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
 }
Beispiel #4
0
 /**
  * Removes a single tag
  *
  * @param $tagName string
  */
 private function removeTag($tagName)
 {
     $tagName = trim($tagName);
     $normalizer = config('tagging.normalizer');
     $normalizer = empty($normalizer) ? '\\Conner\\Tagging\\TaggingUtil::slug' : $normalizer;
     $tagSlug = call_user_func($normalizer, $tagName);
     if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
         TaggingUtil::decrementCount($tagName, $tagSlug, $count);
     }
 }
Beispiel #5
0
 /**
  * Removes a single tag
  * 
  * @param $tagName string
  */
 private function removeTag($tagName)
 {
     $tagName = trim($tagName);
     $tagSlug = TaggingUtil::slug($tagName);
     if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
         TaggingUtil::decrementCount($tagName, $tagSlug, $count);
     }
 }