How to use Tag class

Best Cucumber Common Library code snippet using Tag

Tag.php

Source:Tag.php Github

copy

Full Screen

...16 along with ActiveLink PHP XML Package; if not, write to the Free Software17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/19/**20 * Tag class provides a base for parsing, modifying, outputting and creating XML tags21 * @class Tag22 * @package org.active-link.xml23 * @author Zurab Davitiani24 * @version 0.4.025 * @see XML26 */27class Tag {28 // protected variables29 var $tagStartOpen;30 var $tagStartClose;31 var $tagClose;32 var $tagEndOpen;33 var $tagEndClose;34 var $tagName;35 var $tagContent;36 var $tagAttributes;37 var $tagAttributeSeparator;38 var $tagAttributeSeparators;39 var $tagAttributeAssignment;40 var $tagAttributeValueQuote;41 var $FORMAT_NONE;42 var $FORMAT_INDENT;43 var $tagFormat;44 var $tagFormatIndentLevel;45 var $tagFormatEndTag;46 var $tagFormatNewLine = "\n";47 var $tagFormatIndent = "\t";48 /**49 * Constructor creates a tag object with the specified name and tag content50 * @method Tag51 * @param optional string name52 * @param optional string content53 * @returns none54 */55 function Tag($name = "", $content = "") {56 $this->tagStartOpen = "<";57 $this->tagStartClose = ">";58 $this->tagClose = "/>";59 $this->tagEndOpen = "</";60 $this->tagEndClose = ">";61 $this->setTagName($name);62 $this->setTagContent($content);63 $this->tagAttributes = array();64 $this->tagAttributeSeparator = " ";65 $this->tagAttributeSeparators = array(" ", "\n", "\r", "\t");66 $this->tagAttributeAssignment = "=";67 $this->tagAttributeValueQuote = '"';68 $this->FORMAT_NONE = 0;69 $this->FORMAT_INDENT = 1;70 $this->tagFormat = $this->FORMAT_NONE;71 $this->tagFormatIndentLevel = 0;72 $this->tagFormatEndTag = false;73 }74 /**75 * Find out whether attribute exists76 * @method attributeExists77 * @param string attrName78 * @returns true if attribute exists, false otherwise79 */80 function attributeExists($attrName) {81 return array_key_exists($attrName, $this->tagAttributes);82 }83 /**84 * Get attribute value by its name85 * @method getTagAttribute86 * @param string attrName87 * @returns string attribute value88 */89 function getTagAttribute($attrName) {90 return $this->tagAttributes[$attrName];91 }92 /**93 * Get tag content string94 * @method getTagContent95 * @returns string tag content96 */97 function getTagContent() {98 return $this->tagContent;99 }100 /**101 * Get tag name string102 * @method getTagName103 * @returns string tag name104 */105 function getTagName() {106 return $this->tagName;107 }108 /**109 * Get complete tag string with its attributes and content110 * @method getTagString111 * @returns string tag string112 */113 function getTagString() {114 $formatTagBegin = "";115 $formatTagEnd = "";116 $formatContent = "";117 if($this->tagFormat == $this->FORMAT_INDENT) {118 if($this->tagFormatIndentLevel > 0)119 $formatTagBegin = $this->tagFormatNewLine . str_repeat($this->tagFormatIndent, $this->tagFormatIndentLevel);120 if($this->tagFormatEndTag)121 $formatTagEnd = $this->tagFormatNewLine . str_repeat($this->tagFormatIndent, $this->tagFormatIndentLevel);122 }123 $tagString = $formatTagBegin . $this->getTagStringBegin() . $formatContent . $this->tagContent . $formatTagEnd . $this->getTagStringEnd();124 return $tagString;125 }126 /**127 * Get beginning of the tag string, i.e. its name attributes up until tag contents128 * @method getTagStringBegin129 * @returns string beginning of the tag string130 */131 function getTagStringBegin() {132 $tagString = "";133 if($this->tagName != "") {134 $tagString .= $this->tagStartOpen . $this->tagName;135 foreach($this->tagAttributes as $attrName => $attrValue) {136 $tagString .= $this->tagAttributeSeparator . $attrName . $this->tagAttributeAssignment . $this->tagAttributeValueQuote . $attrValue . $this->tagAttributeValueQuote;137 }138 if($this->tagContent == "")139 $tagString .= $this->tagAttributeSeparator . $this->tagClose;140 else141 $tagString .= $this->tagStartClose;142 }143 return $tagString;144 }145 /**146 * Get ending of the tag string, i.e. its closing tag147 * @method getTagStringEnd148 * @returns string close tag if tag is not short-handed, empty string otherwise149 */150 function getTagStringEnd() {151 $tagString = "";152 if($this->tagName != "" && $this->tagContent != "")153 $tagString .= $this->tagEndOpen . $this->tagName . $this->tagEndClose;154 return $tagString;155 }156 /**157 * Remove all tag attributes158 * @method removeAllAttributes159 * @returns none160 */161 function removeAllAttributes() {162 $this->tagAttributes = array();163 }164 /**165 * Remove a tag attribute by its name166 * @method removeAttribute167 * @returns none168 */169 function removeAttribute($attrName) {170 unset($this->tagAttributes[$attrName]);171 }172 /**173 * Reset the tag object - set name, content to empty strings, and reset all attributes174 * @method resetTag175 * @returns none176 */177 function resetTag() {178 $this->setTagName("");179 $this->setTagContent("");180 $this->removeAllAttributes();181 }182 /**183 * Create or modify an existing attribute by supplying attribute name and value184 * @method setAttribute185 * @param string attrName186 * @param string attrValue187 * @returns none188 */189 function setAttribute($attrName, $attrValue) {190 $this->tagAttributes[$attrName] = $attrValue;191 }192 /**193 * Set contents of the tag194 * @method setTagContent195 * @param string content196 * @returns none197 */198 function setTagContent($content) {199 $this->tagContent = $content;200 }201 /**202 * Set tag formatting option by specifying tagFormat to 0 (none), or 1 (indented)203 * @method setTagFormat204 * @param int tagFormat205 * @param optional int tagFormatIndentLevel206 * @returns none207 */208 function setTagFormat($tagFormat, $tagFormatIndentLevel = 0) {209 $this->tagFormat = $tagFormat;210 $this->tagFormatIndentLevel = $tagFormatIndentLevel;211 }212 /**213 * Set whether closing of the tag should be formatted or not214 * @method setTagFormatEndTag215 * @param optional boolean formatEndTag216 * @returns none217 */218 function setTagFormatEndTag($formatEndTag = true) {219 $this->tagFormatEndTag = $formatEndTag;220 }221 /**222 * Parse a string containing a tag into the tag object, this will parse the first tag found223 * @method setTagFromString224 * @param string tagString225 * @returns array array of [0]=>index of the beginning of the tag, [1]=>index where tag ended226 */227 function setTagFromString($tagString) {228 $i = 0;229 $j = 0;230 $tagStartOpen = $tagStartClose = $tagNameStart = $tagNameEnd = $tagContentStart = $tagContentEnd = $tagEndOpen = $tagEndClose = 0;231 $tagName = $tagContent = "";232 $tagShort = false;233 $tagAttributes = array();234 $success = true;235 $tagFound = false;236 while(!$tagFound && $i < strlen($tagString)) {237 // look for start tag character238 $i = strpos($tagString, $this->tagStartOpen, $i);239 if($i === false)240 break;241 // if tag name starts from alpha character we found the tag242 if(ctype_alpha(substr($tagString, $i + 1, 1)))243 $tagFound = true;244 // else continue searching245 else246 $i ++;247 }248 // if no tag found set success to false249 if(!$tagFound)250 $success = false;251 // if so far so good continue with found tag name252 if($success) {253 $tagStartOpen = $i;254 $tagNameStart = $i + 1;255 // search where tag name would end256 // search for a space separator to account for attributes257 $separatorPos = array();258 for($counter = 0; $counter < count($this->tagAttributeSeparators); $counter ++) {259 $separatorPosTemp = strpos($tagString, $this->tagAttributeSeparators[$counter], $tagStartOpen);260 if($separatorPosTemp !== false)261 $separatorPos[] = $separatorPosTemp;262 }263 //$i = strpos($tagString, $this->tagAttributeSeparator, $tagStartOpen);264 if(count($separatorPos) > 0)265 $i = min($separatorPos);266 else267 $i = false;268 // search for tag close character269 $j = strpos($tagString, $this->tagStartClose, $tagStartOpen);270 // search for short tag (no content)271 $k = strpos($tagString, $this->tagClose, $tagStartOpen);272 // if tag close character is not found then no tag exists, set success to false273 if($j === false)274 $success = false;275 // if tag short close found before tag close, then tag is short276 if($k !== false && $k < $j)277 $tagShort = true;278 }279 // if so far so good set tag name correctly280 if($success) {281 // if space separator not found or it is found after the tag close char282 if($i === false || $i > $j) {283 if($tagShort)284 $tagNameEnd = $k;285 else286 $tagNameEnd = $j;287 $tagStartClose = $j;288 }289 // else if tag attributes exist290 else {291 $tagNameEnd = $i;292 $tagStartClose = $j;293 // parse attributes294 $tagAttributesStart = $i + strlen($this->tagAttributeSeparator);295 $attrString = trim(substr($tagString, $tagAttributesStart, $j - $tagAttributesStart));296 $attrArray = explode($this->tagAttributeValueQuote, $attrString);297 $attrCounter = 0;298 while($attrCounter < count($attrArray) - 1) {299 $attributeName = trim(str_replace($this->tagAttributeAssignment, "", $attrArray[$attrCounter]));300 $attributeValue = $attrArray[$attrCounter + 1];301 $tagAttributes[$attributeName] = $attributeValue;302 $attrCounter += 2;303 }304 }305 $tagName = rtrim(substr($tagString, $tagNameStart, $tagNameEnd - $tagNameStart));306 if(!$tagShort) {307 $tagContentStart = $tagStartClose + 1;308 // look for ending of the tag after tag content309 $j = $tagContentStart;310 $tagCloseFound = false;311 // while loop will find the k-th tag close312 // start with one since we have one tag open313 $k = 1;314 while(!$tagCloseFound && $success) {315 // find k-th tag close from j316 $n = $j - 1;317 for($skip = 0; $skip < $k; $skip ++) {318 $n ++;319 $tempPos = strpos($tagString, $this->tagEndOpen . $tagName . $this->tagEndClose, $n);320 if($tempPos !== false)321 $n = $tempPos;322 else {323 $success = false;324 break;325 }326 }327 // if success, find number of tag opens before the tag close328 $k = 0;329 if($success) {330 $tempString = substr($tagString, $j, $n - $j);331 $tempNewPos = 0;332 do {333 $tempPos = strpos($tempString, $this->tagStartOpen . $tagName, $tempNewPos);334 if($tempPos !== false) {335 $tempPosChar = substr($tempString, $tempPos + strlen($this->tagStartOpen . $tagName), 1);336 $tagEndArray = $this->tagAttributeSeparators;337 $tagEndArray[] = $this->tagEndClose;338 $tempPosTagEnded = array_search($tempPosChar, $tagEndArray);339 if($tempPosTagEnded !== false && $tempPosTagEnded !== NULL) {340 $tempStartClose = strpos($tempString, $this->tagStartClose, $tempPos);341 $tempStartShortClose = strpos($tempString, $this->tagClose, $tempPos);342 // if open tag found increase counter343 if($tempStartClose !== false && ($tempStartShortClose === false || $tempStartClose < $tempStartShortClose))344 $k ++;345 $tempNewPos = $tempPos + strlen($this->tagStartOpen . $tagName);346 }347 else348 $tempNewPos = $tempPos + strlen($this->tagStartOpen . $tagName);349 }350 } while($tempPos !== false);351 }352 // if no tags opened we found the tag close353 if($k == 0)354 $tagCloseFound = true;355 // else set new j356 else {357 $j = $n + strlen($this->tagEndOpen . $tagName . $this->tagEndClose);358 }359 }360 if($tagCloseFound)361 $i = $n;362 else363 $success = false;364 }365 }366 // if so far so good, then we have everything we need! set the object367 if($success) {368 if(!$tagShort) {369 $tagContentEnd = $i;370 $tagContent = substr($tagString, $tagContentStart, $tagContentEnd - $tagContentStart);371 $tagEndOpen = $i;372 $tagEndClose = $tagEndOpen + strlen($this->tagEndOpen . $tagName . $this->tagEndClose);373 }374 else375 $tagEndClose = $tagStartClose + strlen($this->tagStartClose);376 $this->setTagName($tagName);377 $this->setTagContent($tagContent);378 $this->tagAttributes = $tagAttributes;379 }380 if($success)381 return array($tagStartOpen, $tagEndClose);382 else383 return false;384 }385 /**386 * Set tag name387 * @method setTagName388 * @param string name389 * @returns none390 */391 function setTagName($name) {392 $this->tagName = $name;393 }394}395?>...

Full Screen

Full Screen

tags.php

Source:tags.php Github

copy

Full Screen

1<?php2use Kirby\Cms\Html;3use Kirby\Cms\Url;4use Kirby\Text\KirbyTag;5use Kirby\Toolkit\F;6use Kirby\Toolkit\Str;7/**8 * Default KirbyTags definition9 */10return [11 /**12 * Date13 */14 'date' => [15 'attr' => [],16 'html' => function ($tag) {17 return strtolower($tag->date) === 'year' ? date('Y') : date($tag->date);18 }19 ],20 /**21 * Email22 */23 'email' => [24 'attr' => [25 'class',26 'rel',27 'target',28 'text',29 'title'30 ],31 'html' => function ($tag) {32 return Html::email($tag->value, $tag->text, [33 'class' => $tag->class,34 'rel' => $tag->rel,35 'target' => $tag->target,36 'title' => $tag->title,37 ]);38 }39 ],40 /**41 * File42 */43 'file' => [44 'attr' => [45 'class',46 'download',47 'rel',48 'target',49 'text',50 'title'51 ],52 'html' => function ($tag) {53 if (!$file = $tag->file($tag->value)) {54 return $tag->text;55 }56 // use filename if the text is empty and make sure to57 // ignore markdown italic underscores in filenames58 if (empty($tag->text) === true) {59 $tag->text = str_replace('_', '\_', $file->filename());60 }61 return Html::a($file->url(), $tag->text, [62 'class' => $tag->class,63 'download' => $tag->download !== 'false',64 'rel' => $tag->rel,65 'target' => $tag->target,66 'title' => $tag->title,67 ]);68 }69 ],70 /**71 * Gist72 */73 'gist' => [74 'attr' => [75 'file'76 ],77 'html' => function ($tag) {78 return Html::gist($tag->value, $tag->file);79 }80 ],81 /**82 * Image83 */84 'image' => [85 'attr' => [86 'alt',87 'caption',88 'class',89 'height',90 'imgclass',91 'link',92 'linkclass',93 'rel',94 'target',95 'title',96 'width'97 ],98 'html' => function ($tag) {99 if ($tag->file = $tag->file($tag->value)) {100 $tag->src = $tag->file->url();101 $tag->alt = $tag->alt ?? $tag->file->alt()->or(' ')->value();102 $tag->title = $tag->title ?? $tag->file->title()->value();103 $tag->caption = $tag->caption ?? $tag->file->caption()->value();104 } else {105 $tag->src = Url::to($tag->value);106 }107 $link = function ($img) use ($tag) {108 if (empty($tag->link) === true) {109 return $img;110 }111 if ($link = $tag->file($tag->link)) {112 $link = $link->url();113 } else {114 $link = $tag->link === 'self' ? $tag->src : $tag->link;115 }116 return Html::a($link, [$img], [117 'rel' => $tag->rel,118 'class' => $tag->linkclass,119 'target' => $tag->target120 ]);121 };122 $image = Html::img($tag->src, [123 'width' => $tag->width,124 'height' => $tag->height,125 'class' => $tag->imgclass,126 'title' => $tag->title,127 'alt' => $tag->alt ?? ' '128 ]);129 if ($tag->kirby()->option('kirbytext.image.figure', true) === false) {130 return $link($image);131 }132 // render KirbyText in caption133 if ($tag->caption) {134 $tag->caption = [$tag->kirby()->kirbytext($tag->caption, [], true)];135 }136 return Html::figure([ $link($image) ], $tag->caption, [137 'class' => $tag->class138 ]);139 }140 ],141 /**142 * Link143 */144 'link' => [145 'attr' => [146 'class',147 'lang',148 'rel',149 'role',150 'target',151 'title',152 'text',153 ],154 'html' => function ($tag) {155 if (empty($tag->lang) === false) {156 $tag->value = Url::to($tag->value, $tag->lang);157 }158 return Html::a($tag->value, $tag->text, [159 'rel' => $tag->rel,160 'class' => $tag->class,161 'role' => $tag->role,162 'title' => $tag->title,163 'target' => $tag->target,164 ]);165 }166 ],167 /**168 * Tel169 */170 'tel' => [171 'attr' => [172 'class',173 'rel',174 'text',175 'title'176 ],177 'html' => function ($tag) {178 return Html::tel($tag->value, $tag->text, [179 'class' => $tag->class,180 'rel' => $tag->rel,181 'title' => $tag->title182 ]);183 }184 ],185 /**186 * Twitter187 */188 'twitter' => [189 'attr' => [190 'class',191 'rel',192 'target',193 'text',194 'title'195 ],196 'html' => function ($tag) {197 // get and sanitize the username198 $username = str_replace('@', '', $tag->value);199 // build the profile url200 $url = 'https://twitter.com/' . $username;201 // sanitize the link text202 $text = $tag->text ?? '@' . $username;203 // build the final link204 return Html::a($url, $text, [205 'class' => $tag->class,206 'rel' => $tag->rel,207 'target' => $tag->target,208 'title' => $tag->title,209 ]);210 }211 ],212 /**213 * Video214 */215 'video' => [216 'attr' => [217 'autoplay',218 'caption',219 'controls',220 'class',221 'height',222 'loop',223 'muted',224 'poster',225 'preload',226 'style',227 'width',228 ],229 'html' => function ($tag) {230 // all available video tag attributes231 $availableAttrs = KirbyTag::$types[$tag->type]['attr'];232 // global video tag options233 $attrs = $tag->kirby()->option('kirbytext.video', []);234 $options = $attrs['options'] ?? [];235 // removes options from attributes236 if (isset($attrs['options']) === true) {237 unset($attrs['options']);238 }239 // injects default values from global options240 // applies only defined attributes to safely update tag props241 foreach ($attrs as $key => $value) {242 if (243 in_array($key, $availableAttrs) === true &&244 (isset($tag->{$key}) === false || $tag->{$key} === null)245 ) {...

Full Screen

Full Screen

TagAdminTest.php

Source:TagAdminTest.php Github

copy

Full Screen

1<?php2namespace Mars\Test\Unit;3class TagAdminTest extends \PHPUnit_Framework_TestCase4{5 protected static $tag_titles = [6 [['PHP', 'en-us'],],7 [['html', 'en-us'],],8 [['css', 'en-us'],],9 [['Linux', 'en-us']],10 [['Javascript', 'en-us']],11 [['node.js', 'en-us']],12 [['Art', 'en-us'], ['艺术', 'zh-cn'],],13 [['Design', 'en-us'], ['设计', 'zh-cn'],],14 [['Geek', 'en-us'], ['极客', 'zh-cn'],],15 [['Travel', 'en-us'], ['旅游', 'zh-cn'],],16 [['Music', 'en-us'], ['音乐', 'zh-cn'],],17 [['Sports', 'en-us'], ['体育', 'zh-cn']],18 [['Algorithms', 'en-us'], ['算法', 'zh-cn']],19 [['Websites', 'en-us'], ['网站', 'zh-cn']],20 [['Facebook', 'en-us'], ['脸书', 'zh-cn']],21 [['Google', 'en-us'], ['谷歌', 'zh-cn']],22 [['Microsoft', 'en-us'], ['微软', 'zh-cn']],23 ];24 protected static $tag_set = [];25 public static function tearDownAfterClass()26 {27 $tag_admin_service = service('tag_admin');28 foreach (self::$tag_titles as $titles) {29 foreach ($titles as $title) {30 $tag_admin_service->deleteTag(['title' => $title[0]]);31 }32 }33 }34 public function provideTagTitles()35 {36 $tag_titles = [];37 foreach (self::$tag_titles as $titles) {38 $tag_titles[] = $titles[0];39 }40 return $tag_titles;41 }42 /**43 * @dataProvider provideTagTitles44 */45 public function testSaveTag($title, $locale_key)46 {47 $locale_id = locale_set()->getId($locale_key);48 $tag_service = service('tag_admin');49 $pack = service('tag_admin')->saveTag($title, $locale_id);50 $this->assertTrue($pack->isOk());51 $tag_id = $pack->getItem('tag_id');52 $tag = $tag_service->findTag(['tag_id' => $tag_id]);53 $this->assertEquals($title, $tag->getTagTitle($locale_id));54 self::$tag_set[$tag_id][$locale_id] = $title;55 }56 /**57 * @depends testSaveTag58 */59 public function testCreateTagMainError()60 {61 $tag_admin_service = service('tag_admin');62 $pack = $tag_admin_service->createTagMain(63 0,64 0,65 'tag-title-for-test',66 'tag-main-for-test',67 'tag-zcode-for-test'68 );69 $this->assertFalse($pack->isOk());70 $this->assertEquals('not-positive', $pack->getError('tag_id'));71 $pack = $tag_admin_service->createTagMain(1, 0, '', '', '');72 $this->assertFalse($pack->isOk());73 $this->assertEquals('not-positive', $pack->getError('locale'));74 $pack = $tag_admin_service->createTagMain(1, 2, '', '', '');75 $this->assertFalse($pack->isOk());76 $this->assertEquals('empty', $pack->getError('title'));77 $tag_title = self::$tag_titles[0][0];78 $title = $tag_title[0];79 $locale_id = locale_set()->getId($tag_title[1]);80 $tag_main = $tag_admin_service->findTagMain(['title' => $title]);81 $pack = $tag_admin_service->createTagMain(82 $tag_main->tag_id,83 $tag_main->locale_id,84 uniqid('title-'),85 $tag_main->content,86 uniqid('zcode-')87 );88 $this->assertFalse($pack->isOk());89 $this->assertEquals('duplicated', $pack->getError('tag_id-locale'));90 $not_found_tag_id = 9999999999;91 $pack = $tag_admin_service->createTagMain($not_found_tag_id, 1, 'not exist tag id', '');92 $this->assertFalse($pack->isOk());93 $this->assertEquals('not-found', $pack->getError('tag_id'));94 $pack = $tag_admin_service->createTagMain(95 $tag_main->tag_id,96 $locale_id + 1,97 $tag_main->title,98 $tag_main->content,99 uniqid('zcode-')100 );101 $this->assertFalse($pack->isOk());102 $this->assertEquals('duplicated', $pack->getError('title'));103 $pack = $tag_admin_service->createTagMain(104 $tag_main->tag_id,105 $locale_id + 1,106 uniqid('title-'),107 $tag_main->content,108 $tag_main->zcode109 );110 $this->assertFalse($pack->isOk());111 $this->assertEquals('duplicated', $pack->getError('zcode'));112 }113 /**114 * @depends testCreateTagMainError115 */116 public function testCreateTagMain()117 {118 $tag_admin_service = service('tag_admin');119 foreach (self::$tag_titles as $titles) {120 if (isset($titles[1])) {121 $tag = $tag_admin_service->findTag(['title' => $titles[0][0]]);122 $locale_id = locale_set()->getId($titles[1][1]);123 $title = $titles[1][0];124 $pack = $tag_admin_service->createTagMain($tag->id, $locale_id, $title, '');125 $this->assertTrue($pack->isOk());126 self::$tag_set[$tag->id][$locale_id] = $title;127 }128 }129 }130 /**131 * @depends testCreateTagMain132 */133 public function testUpdateTagMain()134 {135 $tag_admin_service = service('tag_admin');136 $title = '电子';137 $locale_id = locale_set()->getId('zh-cn');138 $pack = $tag_admin_service->saveTag($title, $locale_id);139 $this->assertTrue($pack->isOk());140 $tag_main = $tag_admin_service->findTagMain(['title' => $title]);141 $new_title = '电子设备';142 $pack = $tag_admin_service->updateTagMain($tag_main->tag_id, $tag_main->locale_id, $new_title, '', null);143 $this->assertTrue($pack->isOk());144 $tag = $tag_admin_service->findTag(['tag_id' => $tag_main->tag_id]);145 $this->assertEquals($new_title, $tag->getTagTitle($locale_id));146 $pack = $tag_admin_service->deleteTag(['title' => $title]);147 $pack = $tag_admin_service->deleteTag(['title' => $new_title]);148 }149 /**150 * @depends testUpdateTagMain151 */152 public function testGetTagMainSet()153 {154 $tag_admin_service = service('tag_admin');155 foreach (self::$tag_set as $tag_id => $tag_titles) {156 $tag = $tag_admin_service->findTag(['tag_id' => $tag_id]);157 if (!$tag) {158 continue;159 }160 $tag_main_set = $tag->getTagMainSet();161 $this->assertEquals($tag_main_set->getItemCount(), count($tag_titles));162 $tag_main_set->setCountPerPage(0);163 $tag_main_items = $tag_main_set->getItems();164 foreach ($tag_main_items as $tag_main) {165 $this->assertEquals($tag_titles[$tag_main->locale_id], $tag_main->title);166 }167 }168 }169 /**170 * @depends testGetTagMainSet171 */172 public function testDeleteTagMain()173 {174 $tag_admin_service = service('tag_admin');175 $title = uniqid('China-');176 $locale_id = locale_set()->getId('en-us');177 $pack = $tag_admin_service->saveTag($title, $locale_id);178 $this->assertTrue($pack->isOk());179 $tag = $tag_admin_service->findTag(['tag_id' => $pack->getItem('tag_id')]);180 $tag_id = $tag->id;181 $pack = $tag_admin_service->deleteTagMain(['tag_id' => $tag_id, 'locale_id' => $locale_id]);182 $this->assertTrue($pack->isOk());183 $this->assertEquals(0, $tag->getTagMainSet()->getItemCount());184 $pack = $tag_admin_service->deleteTag(['tag_id' => $tag_id]);185 }186 /**187 * @depends testDeleteTagMain188 */189 public function testSchTagSet()190 {191 $tag_admin_service = service('tag_admin');192 $tag_set = $tag_admin_service->schTagSet();193 foreach ($tag_set->getItems() as $tag) {194 if (isset(self::$tag_set[$tag->id])) {195 $tag_arr = self::$tag_set[$tag->id];196 foreach ($tag_arr as $locale_id => $title) {197 $this->assertEquals($title, $tag->getTagTitle($locale_id));198 }199 }200 }201 $tag_set = $tag_admin_service->schTagSet(['keywords' => 'Trav']);202 foreach ($tag_set->getItems() as $tag) {203 $tag_arr = self::$tag_set[$tag->id];204 foreach ($tag_arr as $locale_id => $title) {205 $this->assertEquals($title, $tag->getTagTitle($locale_id));206 }207 }208 }209 /**210 * @depends testSchTagSet211 */212 public function testActivateTag()213 {214 $title = uniqid('title-');215 $locale_id = locale_set()->getId('en-us');216 $tag_admin_service = service('tag_admin');217 $pack = $tag_admin_service->saveTag($title, $locale_id);218 $this->assertTrue($pack->isOk());219 $tag_id = $pack->getItem('tag_id');220 $tag = $tag_admin_service->findTag(['title' => $title]);221 $this->assertEquals($tag_id, $tag->id);222 $pack = $tag_admin_service->deactivateTagById($tag_id);223 $tag = $tag_admin_service->findTag(['title' => $title]);224 $this->assertFalse($tag);225 $tag = $tag_admin_service->findTag(['title' => $title, 'status' => null]);226 $this->assertEquals(0, $tag->status);227 $pack = $tag_admin_service->activateTagById($tag_id);228 $this->assertTrue($pack->isOk());229 $tag = $tag_admin_service->findTag(['title' => $title, 'status' => null]);230 $this->assertEquals(1, $tag->status);231 $tag_admin_service->deleteTag(['tag_id' => $tag_id]);232 }233}...

Full Screen

Full Screen

Tag

Using AI Code Generation

copy

Full Screen

1require_once('Tag.php');2$tag = new Tag();3$tag->setTag('div');4$tag->setAttr('id', 'div1');5$tag->setAttr('class', 'div1');6$tag->setAttr('style', 'border:1px solid black');7$tag->setAttr('style', 'width:200px');8$tag->setAttr('style', 'height:100px');9$tag->setAttr('style', 'float:left');10$tag->setAttr('style', 'clear:left');11$tag->setAttr('style', 'margin:10px');12$tag->setAttr('style', 'padding:10px');13$tag->setAttr('style', 'background-color:#FFFF00');14$tag->setAttr('style', 'font-size:16px');15$tag->setAttr('style', 'color:#000000');16$tag->setAttr('style', 'text-align:center');17$tag->setAttr('style', 'vertical-align:middle');18$tag->setAttr('style', 'line-height:80px');19$tag->setAttr('style', 'font-family:Arial, Helvetica, sans-serif');20$tag->setAttr('style', 'font-weight:bold');21$tag->setAttr('style', 'font-style:italic');22$tag->setAttr('style', 'text-decoration:underline');23$tag->setAttr('style', 'text-transform:uppercase');24$tag->setAttr('style', 'text-shadow:1px 1px 1px #000000');25$tag->setAttr('style', 'text-decoration:blink');26$tag->setAttr('style', 'text-decoration:line-through');27$tag->setAttr('style', 'text-decoration:overline');28$tag->setAttr('style', 'text-decoration:none');29$tag->setAttr('style', 'text-decoration:underline');30$tag->setAttr('style', 'text-decoration:overline');31$tag->setAttr('style', 'text-decoration:line-through');32$tag->setAttr('style', 'text-decoration:blink');33$tag->setAttr('style', 'text-decoration:none');34$tag->setAttr('style', 'text-shadow:1px 1px 1px #000000');35$tag->setAttr('style', 'text-shadow:1px 1px 1px #000000

Full Screen

Full Screen

Tag

Using AI Code Generation

copy

Full Screen

1$tag = new Tag();2$tag->setTag('tag1');3$tag->setTag('tag2');4$tag->setTag('tag3');5$tag->setTag('tag4');6$tag->setTag('tag5');7$tag->setTag('tag6');8$tag->setTag('tag7');9$tag->setTag('tag8');10$tag->setTag('tag9');11$tag->setTag('tag10');12$tag->setTag('tag11');13$tag->setTag('tag12');14$tag->setTag('tag13');15$tag->setTag('tag14');16$tag->setTag('tag15');17$tag->setTag('tag16');18$tag->setTag('tag17');19$tag->setTag('tag18');20$tag->setTag('tag19');21$tag->setTag('tag20');22$tag->setTag('tag21');23$tag->setTag('tag22');24$tag->setTag('tag23');25$tag->setTag('tag24');26$tag->setTag('tag25');27$tag->setTag('tag26');28$tag->setTag('tag27');29$tag->setTag('tag28');30$tag->setTag('tag29');31$tag->setTag('tag30');32$tag->setTag('tag31');33$tag->setTag('tag32');34$tag->setTag('tag33');35$tag->setTag('tag34');36$tag->setTag('tag35');37$tag->setTag('tag36');38$tag->setTag('tag37');39$tag->setTag('tag38');40$tag->setTag('tag39');41$tag->setTag('tag40');42$tag->setTag('tag41');43$tag->setTag('tag42');44$tag->setTag('tag43');45$tag->setTag('tag44');46$tag->setTag('tag45');47$tag->setTag('tag46');48$tag->setTag('tag47');49$tag->setTag('tag48');50$tag->setTag('tag49');51$tag->setTag('tag50');52$tag->setTag('tag51');53$tag->setTag('tag52');54$tag->setTag('tag53');55$tag->setTag('tag54');

Full Screen

Full Screen

Tag

Using AI Code Generation

copy

Full Screen

1require_once __DIR__ . '/../../vendor/autoload.php';2use Cucumber\Common\Tag;3$tag = new Tag();4$tag->tag('tag');5$tag->tag('tag1');6$tag->tag('tag2');7$tag->tag('tag3');8$tag->tag('tag4');9$tag->tag('tag5');10$tag->tag('tag6');11$tag->tag('tag7');12$tag->tag('tag8');13$tag->tag('tag9');14$tag->tag('tag10');15$tag->tag('tag11');16$tag->tag('tag12');17$tag->tag('tag13');18$tag->tag('tag14');19$tag->tag('tag15');20$tag->tag('tag16');21$tag->tag('tag17');22$tag->tag('tag18');23$tag->tag('tag19');24$tag->tag('tag20');25$tag->tag('tag21');26$tag->tag('tag22');27$tag->tag('tag23');28$tag->tag('tag24');29$tag->tag('tag25');30$tag->tag('tag26');31$tag->tag('tag27');32$tag->tag('tag28');33$tag->tag('tag29');34$tag->tag('tag30');35$tag->tag('tag31');36$tag->tag('tag32');37$tag->tag('tag33');38$tag->tag('tag34');39$tag->tag('tag35');40$tag->tag('tag36');41$tag->tag('tag37');42$tag->tag('tag38');43$tag->tag('tag39');44$tag->tag('tag40');45$tag->tag('tag41');46$tag->tag('tag42');47$tag->tag('tag43');48$tag->tag('tag44');49$tag->tag('tag45');50$tag->tag('tag46');51$tag->tag('tag47');52$tag->tag('tag48');53$tag->tag('tag49');54$tag->tag('tag50');55$tag->tag('tag51');56$tag->tag('tag52');57$tag->tag('tag53');58$tag->tag('tag54');59$tag->tag('tag55');60$tag->tag('tag56');61$tag->tag('tag57

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cucumber Common Library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in Tag

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful