How to use getVersion method of builder class

Best Atoum code snippet using builder.getVersion

CategoryUpdateTest.php

Source:CategoryUpdateTest.php Github

copy

Full Screen

...77 $updateAction = new CategoryChangeNameActionModel();78 $updateAction->setName($newName);79 $updateActionCollection = new CategoryUpdateActionCollection();80 $updateActionCollection->add($updateAction);81 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())82 ->withActions($updateActionCollection)->build();83 $request = $builder->with()->categories()->withId($category->getId())84 ->post($categoryUpdate);85 $categoryQueryResponse = $request->execute();86 $this->assertInstanceOf(Category::class, $categoryQueryResponse);87 $this->assertSame($randomName, $categoryQueryResponse->getName()->current());88 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());89 return $categoryQueryResponse;90 }91 );92 }93 public function testChangeNameWithKey()94 {95 $builder = $this->getApiBuilder();96 CategoryFixture::withUpdateableCategory(97 $builder,98 function (Category $category) use ($builder) {99 $randomName = 'new name-' . CategoryFixture::uniqueCategoryString();100 $newName = LocalizedStringBuilder::of()->put('en', $randomName)->build();101 $updateAction = new CategoryChangeNameActionModel();102 $updateAction->setName($newName);103 $updateActionCollection = new CategoryUpdateActionCollection();104 $updateActionCollection->add($updateAction);105 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())106 ->withActions($updateActionCollection)->build();107 $request = $builder->with()->categories()->withKey($category->getKey())108 ->post($categoryUpdate);109 $categoryQueryResponse = $request->execute();110 $this->assertInstanceOf(Category::class, $categoryQueryResponse);111 $this->assertSame($randomName, $categoryQueryResponse->getName()->current());112 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());113 return $categoryQueryResponse;114 }115 );116 }117 public function testUpdateLocalizedName()118 {119 $builder = $this->getApiBuilder();120 CategoryFixture::withUpdateableCategory(121 $builder,122 function (Category $category) use ($builder) {123 $randomName = 'new name-' . CategoryFixture::uniqueCategoryString();124 $newName = LocalizedStringBuilder::of()->put('en', $randomName)->put('en-US', $randomName)->build();125 $updateAction = new CategoryChangeNameActionModel();126 $updateAction->setName($newName);127 $updateActionCollection = new CategoryUpdateActionCollection();128 $updateActionCollection->add($updateAction);129 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())130 ->withActions($updateActionCollection)->build();131 $request = $builder->with()->categories()->withKey($category->getKey())132 ->post($categoryUpdate);133 $categoryQueryResponse = $request->execute();134 $this->assertJsonStringEqualsJsonString('{"en":"' . $randomName . '", "en-US":"' . $randomName . '"}', json_encode($newName));135 $this->assertInstanceOf(Category::class, $categoryQueryResponse);136 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());137 return $categoryQueryResponse;138 }139 );140 }141 public function testChangeOrderHint()142 {143 $builder = $this->getApiBuilder();144 CategoryFixture::withUpdateableCategory(145 $builder,146 function (Category $category) use ($builder) {147 $hint = '0.9' . trim(mt_rand(1, CategoryFixture::RAND_MAX));148 $updateAction = new CategoryChangeOrderHintActionModel();149 $updateAction->setOrderHint($hint);150 $updateActionCollection = new CategoryUpdateActionCollection();151 $updateActionCollection->add($updateAction);152 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())153 ->withActions($updateActionCollection)->build();154 $request = $builder->with()->categories()->withId($category->getId())155 ->post($categoryUpdate);156 $categoryQueryResponse = $request->execute();157 $this->assertInstanceOf(Category::class, $categoryQueryResponse);158 $this->assertSame($hint, $categoryQueryResponse->getOrderHint());159 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());160 return $categoryQueryResponse;161 }162 );163 }164 public function testChangeParent()165 {166 $builder = $this->getApiBuilder();167 CategoryFixture::withCategory(168 $builder,169 function (Category $category1) use ($builder) {170 CategoryFixture::withUpdateableCategory(171 $builder,172 function (Category $category2) use ($builder, $category1) {173 $categoryResourceIdentifier = CategoryResourceIdentifierBuilder::of()->withId($category1->getId())->build();174 $updateAction = new CategoryChangeParentActionModel();175 $updateAction->setParent($categoryResourceIdentifier);176 $updateActionCollection = new CategoryUpdateActionCollection();177 $updateActionCollection->add($updateAction);178 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category2->getVersion())179 ->withActions($updateActionCollection)->build();180 $request = $builder->with()->categories()->withId($category2->getId())181 ->post($categoryUpdate);182 $categoryQueryResponse = $request->execute();183 $this->assertInstanceOf(Category::class, $categoryQueryResponse);184 $this->assertSame($category1->getId(), $categoryQueryResponse->getParent()->getId());185 $this->assertNotSame($category2->getVersion(), $categoryQueryResponse->getVersion());186 return $categoryQueryResponse;187 }188 );189 }190 );191 }192 public function testChangeSlug()193 {194 $builder = $this->getApiBuilder();195 CategoryFixture::withUpdateableCategory(196 $builder,197 function (Category $category) use ($builder) {198 $randomSlug = 'new-slug-' . CategoryFixture::uniqueCategoryString();199 $newSlug = LocalizedStringBuilder::of()->put('en', $randomSlug)->build();200 $updateAction = new CategoryChangeSlugActionModel();201 $updateAction->setSlug($newSlug);202 $updateActionCollection = new CategoryUpdateActionCollection();203 $updateActionCollection->add($updateAction);204 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())205 ->withActions($updateActionCollection)->build();206 $request = $builder->with()->categories()->withId($category->getId())207 ->post($categoryUpdate);208 $categoryQueryResponse = $request->execute();209 $this->assertInstanceOf(Category::class, $categoryQueryResponse);210 $this->assertSame($randomSlug, $categoryQueryResponse->getSlug()->current());211 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());212 return $categoryQueryResponse;213 }214 );215 }216 public function testSetDescription()217 {218 $builder = $this->getApiBuilder();219 CategoryFixture::withUpdateableDraftCategory(220 $builder,221 function (CategoryDraftBuilder $draftBuilder) {222 $randomDescription = 'description-' . CategoryFixture::uniqueCategoryString();223 $description = LocalizedStringBuilder::of()->put('en', $randomDescription)->build();224 $draftBuilder->withDescription($description);225 return $draftBuilder->build();226 },227 function (Category $category) use ($builder) {228 $randomNewDescription = 'new-description-' . CategoryFixture::uniqueCategoryString();229 $newDescription = LocalizedStringBuilder::of()->put('en', $randomNewDescription)->build();230 $updateAction = new CategorySetDescriptionActionModel();231 $updateAction->setDescription($newDescription);232 $updateActionCollection = new CategoryUpdateActionCollection();233 $updateActionCollection->add($updateAction);234 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())235 ->withActions($updateActionCollection)->build();236 $request = $builder->with()->categories()->withId($category->getId())237 ->post($categoryUpdate);238 $categoryQueryResponse = $request->execute();239 $this->assertInstanceOf(Category::class, $categoryQueryResponse);240 $this->assertSame($randomNewDescription, $categoryQueryResponse->getDescription()->current());241 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());242 return $categoryQueryResponse;243 }244 );245 }246 public function testSetExternalId()247 {248 $builder = $this->getApiBuilder();249 CategoryFixture::withUpdateableDraftCategory(250 $builder,251 function (CategoryDraftBuilder $draftBuilder) {252 $externalId = 'externalId-' . CategoryFixture::uniqueCategoryString();253 $draftBuilder->withExternalId($externalId);254 return $draftBuilder->build();255 },256 function (Category $category) use ($builder) {257 $externalId = 'new-external-id-' . CategoryFixture::uniqueCategoryString();258 $updateAction = new CategorySetExternalIdActionModel();259 $updateAction->setExternalId($externalId);260 $updateActionCollection = new CategoryUpdateActionCollection();261 $updateActionCollection->add($updateAction);262 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())263 ->withActions($updateActionCollection)->build();264 $request = $builder->with()->categories()->withId($category->getId())265 ->post($categoryUpdate);266 $categoryQueryResponse = $request->execute();267 $this->assertInstanceOf(Category::class, $categoryQueryResponse);268 $this->assertSame($externalId, $categoryQueryResponse->getExternalId());269 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());270 return $categoryQueryResponse;271 }272 );273 }274 public function testSetMetaDescription()275 {276 $builder = $this->getApiBuilder();277 CategoryFixture::withUpdateableDraftCategory(278 $builder,279 function (CategoryDraftBuilder $draftBuilder) {280 $randomMetaDescription = 'meta-description-' . CategoryFixture::uniqueCategoryString();281 $metaDescription = LocalizedStringBuilder::of()->put('en', $randomMetaDescription)->build();282 $draftBuilder->withMetaDescription($metaDescription);283 return $draftBuilder->build();284 },285 function (Category $category) use ($builder) {286 $randomNewMetaDescription = 'new-description-' . CategoryFixture::uniqueCategoryString();287 $newMetaDescription = LocalizedStringBuilder::of()->put('en', $randomNewMetaDescription)->build();288 $updateAction = new CategorySetMetaDescriptionActionModel();289 $updateAction->setMetaDescription($newMetaDescription);290 $updateActionCollection = new CategoryUpdateActionCollection();291 $updateActionCollection->add($updateAction);292 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())293 ->withActions($updateActionCollection)->build();294 $request = $builder->with()->categories()->withId($category->getId())295 ->post($categoryUpdate);296 $categoryQueryResponse = $request->execute();297 $this->assertInstanceOf(Category::class, $categoryQueryResponse);298 $this->assertSame($randomNewMetaDescription, $categoryQueryResponse->getMetaDescription()->current());299 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());300 return $categoryQueryResponse;301 }302 );303 }304 public function testSetMetaTitle()305 {306 $builder = $this->getApiBuilder();307 CategoryFixture::withUpdateableDraftCategory(308 $builder,309 function (CategoryDraftBuilder $draftBuilder) {310 $randomTitle = 'title-' . CategoryFixture::uniqueCategoryString();311 $title = LocalizedStringBuilder::of()->put('en', $randomTitle)->build();312 $draftBuilder->withMetaTitle($title);313 return $draftBuilder->build();314 },315 function (Category $category) use ($builder) {316 $randomNewTitle = 'new-title-' . CategoryFixture::uniqueCategoryString();317 $newTitle = LocalizedStringBuilder::of()->put('en', $randomNewTitle)->build();318 $updateAction = new CategorySetMetaTitleActionModel();319 $updateAction->setMetaTitle($newTitle);320 $updateActionCollection = new CategoryUpdateActionCollection();321 $updateActionCollection->add($updateAction);322 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())323 ->withActions($updateActionCollection)->build();324 $request = $builder->with()->categories()->withId($category->getId())325 ->post($categoryUpdate);326 $categoryQueryResponse = $request->execute();327 $this->assertInstanceOf(Category::class, $categoryQueryResponse);328 $this->assertSame($randomNewTitle, $categoryQueryResponse->getMetaTitle()->current());329 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());330 return $categoryQueryResponse;331 }332 );333 }334 public function testSetMetaKeywords()335 {336 $builder = $this->getApiBuilder();337 CategoryFixture::withUpdateableDraftCategory(338 $builder,339 function (CategoryDraftBuilder $draftBuilder) {340 $randomAssetKeywords = 'keywords-' . CategoryFixture::uniqueCategoryString();341 $assetKeywords = LocalizedStringBuilder::of()->put('en', $randomAssetKeywords)->build();342 $draftBuilder->withMetaTitle($assetKeywords);343 return $draftBuilder->build();344 },345 function (Category $category) use ($builder) {346 $randomNewAssetKeywords = 'new-keywords-' . CategoryFixture::uniqueCategoryString();347 $newAssetKeywords = LocalizedStringBuilder::of()->put('en', $randomNewAssetKeywords)->build();348 $updateAction = new CategorySetMetaKeywordsActionModel();349 $updateAction->setMetaKeywords($newAssetKeywords);350 $updateActionCollection = new CategoryUpdateActionCollection();351 $updateActionCollection->add($updateAction);352 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())353 ->withActions($updateActionCollection)->build();354 $request = $builder->with()->categories()->withId($category->getId())355 ->post($categoryUpdate);356 $categoryQueryResponse = $request->execute();357 $this->assertInstanceOf(Category::class, $categoryQueryResponse);358 $this->assertSame($randomNewAssetKeywords, $categoryQueryResponse->getMetaKeywords()->current());359 $this->assertNotSame($category->getVersion(), $categoryQueryResponse->getVersion());360 return $categoryQueryResponse;361 }362 );363 }364 public function testAddAsset()365 {366 $builder = $this->getApiBuilder();367 CategoryFixture::withUpdateableCategory(368 $builder,369 function (Category $category) use ($builder) {370 $assetDraft = $this->getAssertDraft();371 $updateAction = new CategoryAddAssetActionModel();372 $updateAction->setAsset($assetDraft);373 $updateActionCollection = new CategoryUpdateActionCollection();374 $updateActionCollection->add($updateAction);375 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())376 ->withActions($updateActionCollection)->build();377 $request = $builder->with()->categories()->withId($category->getId())378 ->post($categoryUpdate);379 $categoryQueryResponse = $request->execute();380 $this->assertInstanceOf(Category::class, $categoryQueryResponse);381 $this->assertNotNull($categoryQueryResponse->getAssets()->current()->getId());382 $this->assertSame(383 $assetDraft->getSources()->current()->getUri(),384 $categoryQueryResponse->getAssets()->current()->getSources()->current()->getUri()385 );386 return $categoryQueryResponse;387 }388 );389 }390 public function testRemoveAsset()391 {392 $builder = $this->getApiBuilder();393 CategoryFixture::withUpdateableDraftCategory(394 $builder,395 function (CategoryDraftBuilder $draftBuilder) {396 $assetDraftCollection = $this->getAssetDraftCollection();397 $draftBuilder->withAssets($assetDraftCollection);398 return $draftBuilder->build();399 },400 function (Category $category) use ($builder) {401 $updateAction = new CategoryRemoveAssetActionModel();402 $updateAction->setAssetId($category->getAssets()->current()->getId());403 $updateActionCollection = new CategoryUpdateActionCollection();404 $updateActionCollection->add($updateAction);405 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())406 ->withActions($updateActionCollection)->build();407 $request = $builder->with()->categories()->withId($category->getId())408 ->post($categoryUpdate);409 $categoryQueryResponse = $request->execute();410 $this->assertInstanceOf(Category::class, $categoryQueryResponse);411 $this->assertCount(0, $categoryQueryResponse->getAssets());412 return $categoryQueryResponse;413 }414 );415 }416 public function testChangeAssetName()417 {418 $builder = $this->getApiBuilder();419 CategoryFixture::withUpdateableDraftCategory(420 $builder,421 function (CategoryDraftBuilder $draftBuilder) {422 $assetDraftCollection = $this->getAssetDraftCollection();423 $draftBuilder->withAssets($assetDraftCollection);424 return $draftBuilder->build();425 },426 function (Category $category) use ($builder) {427 $randomNewName = 'new-name-' . CategoryFixture::uniqueCategoryString();428 $newName = LocalizedStringBuilder::of()->put('en', $randomNewName)->build();429 $updateAction = new CategoryChangeAssetNameActionModel();430 $updateAction->setName($newName);431 $updateAction->setAssetId($category->getAssets()->current()->getId());432 $updateActionCollection = new CategoryUpdateActionCollection();433 $updateActionCollection->add($updateAction);434 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())435 ->withActions($updateActionCollection)->build();436 $request = $builder->with()->categories()->withId($category->getId())437 ->post($categoryUpdate);438 $categoryQueryResponse = $request->execute();439 $this->assertInstanceOf(Category::class, $categoryQueryResponse);440 $this->assertSame(441 $randomNewName,442 $categoryQueryResponse->getAssets()->current()->getName()->current()443 );444 return $categoryQueryResponse;445 }446 );447 }448 public function testSetAssetDescription()449 {450 $builder = $this->getApiBuilder();451 CategoryFixture::withUpdateableDraftCategory(452 $builder,453 function (CategoryDraftBuilder $draftBuilder) {454 $assetDraftCollection = $this->getAssetDraftCollection();455 $draftBuilder->withAssets($assetDraftCollection);456 return $draftBuilder->build();457 },458 function (Category $category) use ($builder) {459 $randomNewDescription = 'new-description-' . CategoryFixture::uniqueCategoryString();460 $newDescription = LocalizedStringBuilder::of()->put('en', $randomNewDescription)->build();461 $updateAction = new CategorySetAssetDescriptionActionModel();462 $updateAction->setDescription($newDescription);463 $updateAction->setAssetId($category->getAssets()->current()->getId());464 $updateActionCollection = new CategoryUpdateActionCollection();465 $updateActionCollection->add($updateAction);466 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())467 ->withActions($updateActionCollection)->build();468 $request = $builder->with()->categories()->withId($category->getId())469 ->post($categoryUpdate);470 $categoryQueryResponse = $request->execute();471 $this->assertInstanceOf(Category::class, $categoryQueryResponse);472 $this->assertSame(473 $randomNewDescription,474 $categoryQueryResponse->getAssets()->current()->getDescription()->current()475 );476 return $categoryQueryResponse;477 }478 );479 }480 public function testSetAssetTags()481 {482 $builder = $this->getApiBuilder();483 CategoryFixture::withUpdateableDraftCategory(484 $builder,485 function (CategoryDraftBuilder $draftBuilder) {486 $assetDraftCollection = $this->getAssetDraftCollection();487 $draftBuilder->withAssets($assetDraftCollection);488 return $draftBuilder->build();489 },490 function (Category $category) use ($builder) {491 $newTag[] = 'new-tag-' . CategoryFixture::uniqueCategoryString();492 $updateAction = new CategorySetAssetTagsActionModel();493 $updateAction->setTags($newTag);494 $updateAction->setAssetId($category->getAssets()->current()->getId());495 $updateActionCollection = new CategoryUpdateActionCollection();496 $updateActionCollection->add($updateAction);497 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())498 ->withActions($updateActionCollection)->build();499 $request = $builder->with()->categories()->withId($category->getId())500 ->post($categoryUpdate);501 $categoryQueryResponse = $request->execute();502 $this->assertInstanceOf(Category::class, $categoryQueryResponse);503 $this->assertSame(504 $newTag,505 $categoryQueryResponse->getAssets()->current()->getTags()506 );507 return $categoryQueryResponse;508 }509 );510 }511 public function testSetAssetSources()512 {513 $builder = $this->getApiBuilder();514 CategoryFixture::withUpdateableDraftCategory(515 $builder,516 function (CategoryDraftBuilder $draftBuilder) {517 $assetDraftCollection = $this->getAssetDraftCollection();518 $draftBuilder->withAssets($assetDraftCollection);519 return $draftBuilder->build();520 },521 function (Category $category) use ($builder) {522 $uri = CategoryFixture::uniqueCategoryString() . '-new.jpq';523 $newSource = AssetSourceBuilder::of()->withUri($uri)->withKey('test');524 $sources = new AssetSourceCollection();525 $sources->add($newSource->build());526 $updateAction = new CategorySetAssetSourcesActionModel();527 $updateAction->setSources($sources);528 $updateAction->setAssetId($category->getAssets()->current()->getId());529 $updateActionCollection = new CategoryUpdateActionCollection();530 $updateActionCollection->add($updateAction);531 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())532 ->withActions($updateActionCollection)->build();533 $request = $builder->with()->categories()->withId($category->getId())534 ->post($categoryUpdate);535 $categoryQueryResponse = $request->execute();536 $this->assertInstanceOf(Category::class, $categoryQueryResponse);537 $this->assertSame(538 $newSource->getUri(),539 $categoryQueryResponse->getAssets()->current()->getSources()->current()->getUri()540 );541 return $categoryQueryResponse;542 }543 );544 }545 public function testSetAssetKey()546 {547 $builder = $this->getApiBuilder();548 CategoryFixture::withUpdateableDraftCategory(549 $builder,550 function (CategoryDraftBuilder $draftBuilder) {551 $assetDraftCollection = $this->getAssetDraftCollection();552 $draftBuilder->withAssets($assetDraftCollection);553 return $draftBuilder->build();554 },555 function (Category $category) use ($builder) {556 $assetKey = uniqid();557 $updateAction = new CategorySetAssetKeyActionModel();558 $updateAction->setAssetKey($assetKey);559 $updateAction->setAssetId($category->getAssets()->current()->getId());560 $updateActionCollection = new CategoryUpdateActionCollection();561 $updateActionCollection->add($updateAction);562 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())563 ->withActions($updateActionCollection)->build();564 $request = $builder->with()->categories()->withId($category->getId())565 ->post($categoryUpdate);566 $categoryQueryResponse = $request->execute();567 $this->assertInstanceOf(Category::class, $categoryQueryResponse);568 $this->assertSame(569 $assetKey,570 $categoryQueryResponse->getAssets()->current()->getKey()571 );572 return $categoryQueryResponse;573 }574 );575 }576 public function testAddAssetWithKey()577 {578 $builder = $this->getApiBuilder();579 CategoryFixture::withUpdateableCategory(580 $builder,581 function (Category $category) use ($builder) {582 $assetKey = uniqid();583 $assetDraft = $this->getAssertDraft($assetKey);584 $updateAction = new CategoryAddAssetActionModel();585 $updateAction->setAsset($assetDraft);586 $updateActionCollection = new CategoryUpdateActionCollection();587 $updateActionCollection->add($updateAction);588 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())589 ->withActions($updateActionCollection)->build();590 $request = $builder->with()->categories()->withId($category->getId())591 ->post($categoryUpdate);592 $categoryQueryResponse = $request->execute();593 $this->assertInstanceOf(Category::class, $categoryQueryResponse);594 $this->assertNotNull($categoryQueryResponse->getAssets()->current()->getId());595 $this->assertSame($assetKey, $categoryQueryResponse->getAssets()->current()->getKey());596 $this->assertSame(597 $assetDraft->getSources()->current()->getUri(),598 $categoryQueryResponse->getAssets()->current()->getSources()->current()->getUri()599 );600 return $categoryQueryResponse;601 }602 );603 }604 public function testRemoveAssetByKey()605 {606 $builder = $this->getApiBuilder();607 CategoryFixture::withUpdateableDraftCategory(608 $builder,609 function (CategoryDraftBuilder $draftBuilder) {610 $assetKey = uniqid();611 $assetDraftCollection = $this->getAssetDraftCollection($assetKey);612 $draftBuilder->withAssets($assetDraftCollection);613 return $draftBuilder->build();614 },615 function (Category $category) use ($builder) {616 $updateAction = new CategoryRemoveAssetActionModel();617 $updateAction->setAssetKey($category->getAssets()->current()->getKey());618 $updateActionCollection = new CategoryUpdateActionCollection();619 $updateActionCollection->add($updateAction);620 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())621 ->withActions($updateActionCollection)->build();622 $request = $builder->with()->categories()->withId($category->getId())623 ->post($categoryUpdate);624 $categoryQueryResponse = $request->execute();625 $this->assertInstanceOf(Category::class, $categoryQueryResponse);626 $this->assertCount(0, $categoryQueryResponse->getAssets());627 return $categoryQueryResponse;628 }629 );630 }631 public function testChangeAssetNameByKey()632 {633 $builder = $this->getApiBuilder();634 CategoryFixture::withUpdateableDraftCategory(635 $builder,636 function (CategoryDraftBuilder $draftBuilder) {637 $assetKey = uniqid();638 $assetDraftCollection = $this->getAssetDraftCollection($assetKey);639 $draftBuilder->withAssets($assetDraftCollection);640 return $draftBuilder->build();641 },642 function (Category $category) use ($builder) {643 $randomNewName = 'new-name-' . CategoryFixture::uniqueCategoryString();644 $newName = LocalizedStringBuilder::of()->put('en', $randomNewName)->build();645 $updateAction = new CategoryChangeAssetNameActionModel();646 $updateAction->setAssetKey($category->getAssets()->current()->getKey());647 $updateAction->setName($newName);648 $updateActionCollection = new CategoryUpdateActionCollection();649 $updateActionCollection->add($updateAction);650 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())651 ->withActions($updateActionCollection)->build();652 $request = $builder->with()->categories()->withId($category->getId())653 ->post($categoryUpdate);654 $categoryQueryResponse = $request->execute();655 $this->assertInstanceOf(Category::class, $categoryQueryResponse);656 $this->assertSame(657 $randomNewName,658 $categoryQueryResponse->getAssets()->current()->getName()->current()659 );660 return $categoryQueryResponse;661 }662 );663 }664 public function testSetAssetDescriptionByKey()665 {666 $builder = $this->getApiBuilder();667 CategoryFixture::withUpdateableDraftCategory(668 $builder,669 function (CategoryDraftBuilder $draftBuilder) {670 $assetKey = uniqid();671 $assetDraftCollection = $this->getAssetDraftCollection($assetKey);672 $draftBuilder->withAssets($assetDraftCollection);673 return $draftBuilder->build();674 },675 function (Category $category) use ($builder) {676 $randomNewDescription = 'new-description-' . CategoryFixture::uniqueCategoryString();677 $newDescription = LocalizedStringBuilder::of()->put('en', $randomNewDescription)->build();678 $updateAction = new CategorySetAssetDescriptionActionModel();679 $updateAction->setAssetKey($category->getAssets()->current()->getKey());680 $updateAction->setDescription($newDescription);681 $updateActionCollection = new CategoryUpdateActionCollection();682 $updateActionCollection->add($updateAction);683 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())684 ->withActions($updateActionCollection)->build();685 $request = $builder->with()->categories()->withId($category->getId())686 ->post($categoryUpdate);687 $categoryQueryResponse = $request->execute();688 $this->assertInstanceOf(Category::class, $categoryQueryResponse);689 $this->assertSame(690 $randomNewDescription,691 $categoryQueryResponse->getAssets()->current()->getDescription()->current()692 );693 return $categoryQueryResponse;694 }695 );696 }697 public function testSetAssetTagsByKey()698 {699 $builder = $this->getApiBuilder();700 CategoryFixture::withUpdateableDraftCategory(701 $builder,702 function (CategoryDraftBuilder $draftBuilder) {703 $assetKey = uniqid();704 $assetDraftCollection = $this->getAssetDraftCollection($assetKey);705 $draftBuilder->withAssets($assetDraftCollection);706 return $draftBuilder->build();707 },708 function (Category $category) use ($builder) {709 $newTag[] = 'new-tag-' . CategoryFixture::uniqueCategoryString();710 $updateAction = new CategorySetAssetTagsActionModel();711 $updateAction->setAssetKey($category->getAssets()->current()->getKey());712 $updateAction->setTags($newTag);713 $updateActionCollection = new CategoryUpdateActionCollection();714 $updateActionCollection->add($updateAction);715 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())716 ->withActions($updateActionCollection)->build();717 $request = $builder->with()->categories()->withId($category->getId())718 ->post($categoryUpdate);719 $categoryQueryResponse = $request->execute();720 $this->assertInstanceOf(Category::class, $categoryQueryResponse);721 $this->assertSame(722 $newTag,723 $categoryQueryResponse->getAssets()->current()->getTags()724 );725 return $categoryQueryResponse;726 }727 );728 }729 public function testSetAssetSourcesByKey()730 {731 $builder = $this->getApiBuilder();732 CategoryFixture::withUpdateableDraftCategory(733 $builder,734 function (CategoryDraftBuilder $draftBuilder) {735 $assetKey = uniqid();736 $assetDraftCollection = $this->getAssetDraftCollection($assetKey);737 $draftBuilder->withAssets($assetDraftCollection);738 return $draftBuilder->build();739 },740 function (Category $category) use ($builder) {741 $assetSource = AssetSourceBuilder::of()742 ->withUri(CategoryFixture::uniqueCategoryString() . '.jpg')->withKey('test');743 $newSource = new AssetSourceCollection();744 $newSource->add($assetSource->build());745 $updateAction = new CategorySetAssetSourcesActionModel();746 $updateAction->setAssetKey($category->getAssets()->current()->getKey());747 $updateAction->setSources($newSource);748 $updateActionCollection = new CategoryUpdateActionCollection();749 $updateActionCollection->add($updateAction);750 $categoryUpdate = CategoryUpdateBuilder::of()->withVersion($category->getVersion())751 ->withActions($updateActionCollection)->build();752 $request = $builder->with()->categories()->withId($category->getId())753 ->post($categoryUpdate);754 $categoryQueryResponse = $request->execute();755 $this->assertInstanceOf(Category::class, $categoryQueryResponse);756 $this->assertStringContainsString(757 $assetSource->getUri(),758 $categoryQueryResponse->getAssets()->current()->getSources()->current()->getUri()759 );760 return $categoryQueryResponse;761 }762 );763 }764}...

Full Screen

Full Screen

Counters.php

Source:Counters.php Github

copy

Full Screen

...22 }23 24 public function getAndIncrement( $counter_name ) {25 26 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/get/increment", '', 'PUT' );27 28 }29 30 public function incrementAndGet( $counter_name ) {31 32 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/increment/get", '', 'PUT' );33 34 }35 36 public function getAndDecrement( $counter_name) {37 38 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/get/decrement", '', 'PUT' );39 40 } 41 42 public function decrementAndGet( $counter_name ) {43 44 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/decrement/get", '', 'PUT' );45 46 } 47 48 public function addAndGet( $counter_name, $number ) {49 50 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/incrementby/get?value=" . $number, '', 'PUT' );51 52 } 53 54 public function getAndAdd( $counter_name, $number ) {55 56 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/get/incrementby?value=" . $number, '', 'PUT' );57 58 } 59 60 public function compareAndSet( $counter_name, $expected, $updated ) {61 62 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/get/compareandset?expected=" . $expected . "&updatedvalue=". $updated, '', 'PUT' );63 64 }65 66 public function get( $counter_name ) {67 68 return RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name, '', 'GET' );69 70 }71 72 public function reset( $counter_name ) {73 74 RequestBuilder::doRequestByUrl( Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name ."/reset", '', 'PUT' );75 76 }77 78}...

Full Screen

Full Screen

getVersion

Using AI Code Generation

copy

Full Screen

1require_once 'builder.php';2$builder = new Builder();3echo $builder->getVersion();4require_once 'builder.php';5$builder = new Builder();6echo $builder->getVersion();7require_once 'builder.php';8$builder = new Builder();9echo $builder->getVersion();10require_once 'builder.php';11$builder = new Builder();12echo $builder->getVersion();13require_once 'builder.php';14$builder = new Builder();15echo $builder->getVersion();16require_once 'builder.php';17$builder = new Builder();18echo $builder->getVersion();19require_once 'builder.php';20$builder = new Builder();21echo $builder->getVersion();22require_once 'builder.php';23$builder = new Builder();24echo $builder->getVersion();25require_once 'builder.php';26$builder = new Builder();27echo $builder->getVersion();28require_once 'builder.php';29$builder = new Builder();30echo $builder->getVersion();31require_once 'builder.php';32$builder = new Builder();33echo $builder->getVersion();34require_once 'builder.php';35$builder = new Builder();36echo $builder->getVersion();37require_once 'builder.php';38$builder = new Builder();39echo $builder->getVersion();40require_once 'builder.php';41$builder = new Builder();42echo $builder->getVersion();

Full Screen

Full Screen

getVersion

Using AI Code Generation

copy

Full Screen

1$builder = new Builder();2echo $builder->getVersion();3$builder = new Builder();4echo $builder->getVersion();5$builder = new Builder();6echo $builder->getVersion();7];8$builder = new Builder();9echo $builder->getVersion();10$builder = new Builder();11echo $builder->getVersion();12$builder = new Builder();13echo $builder->getVersion();14];

Full Screen

Full Screen

getVersion

Using AI Code Generation

copy

Full Screen

1require_once('Builder.php');2$objBuilder = new Builder();3echo $objBuilder->getVersion();4require_once('Builder.php');5$objBuilder = new Builder();6echo $objBuilder->getVersion();7require_once('Builder.php');8$objBuilder = new Builder();9echo $objBuilder->getVersion();10require_once('Builder.php');11$objBuilder = new Builder();12echo $objBuilder->getVersion();13require_once('Builder.php');14$objBuilder = new Builder();15echo $objBuilder->getVersion();16require_once('Builder.php');17$objBuilder = new Builder();18echo $objBuilder->getVersion();19require_once('Builder.php');20$objBuilder = new Builder();21echo $objBuilder->getVersion();22require_once('Builder.php');23$objBuilder = new Builder();24echo $objBuilder->getVersion();25require_once('Builder.php');26$objBuilder = new Builder();27echo $objBuilder->getVersion();28require_once('Builder.php');29$objBuilder = new Builder();30echo $objBuilder->getVersion();31require_once('Builder.php');32$objBuilder = new Builder();33echo $objBuilder->getVersion();34require_once('Builder.php');35$objBuilder = new Builder();36echo $objBuilder->getVersion();37require_once('Builder.php');38$objBuilder = new Builder();39echo $objBuilder->getVersion();40require_once('Builder.php');41$objBuilder = new Builder();

Full Screen

Full Screen

getVersion

Using AI Code Generation

copy

Full Screen

1require_once('builder.php');2$version = Builder::getVersion();3echo $version;4require_once('builder.php');5$version = Builder::getVersion();6echo $version;7require_once('builder.php');8$version = Builder::getVersion();9echo $version;10require_once('builder.php');11$version = Builder::getVersion();12echo $version;13Difference between include() and include_once()14include() include_once() The include() function is used to include the file in the PHP script. The include_once() function is used to include the same file only once in the PHP script. The include() function throws a warning if the file is not found. The include_once() function throws a warning if the file is not found. The include() function throws a fatal error if the file is not found. The include_once() function throws a fatal error if the file is not found. The include() function throws a warning if the file is not found. The include_once() function throws a warning if the file is not found. The include() function throws a fatal error if the file is not found. The include_once() function throws a fatal error if the file is not found. The include() function will include the file multiple times if it is used multiple times in the PHP script. The include_once() function will include the file only once in the PHP script even if it is used multiple times in the PHP script. The include() function will include the file multiple times if it is used multiple

Full Screen

Full Screen

getVersion

Using AI Code Generation

copy

Full Screen

1include_once('builder.php');2$builder = new builder();3echo $builder->getVersion();4include_once('builder.php');5$builder = new builder();6echo $builder->getVersion();7include_once('builder.php');8$builder = new builder();9echo $builder->getVersion();10include_once('builder.php');11$builder = new builder();12echo $builder->getVersion();13include_once('builder.php');14$builder = new builder();15echo $builder->getVersion();16include_once('builder.php');17$builder = new builder();18echo $builder->getVersion();19include_once('builder.php');20$builder = new builder();21echo $builder->getVersion();22include_once('builder.php');23$builder = new builder();24echo $builder->getVersion();25include_once('builder.php');26$builder = new builder();27echo $builder->getVersion();28include_once('builder.php');29$builder = new builder();30echo $builder->getVersion();31include_once('builder.php');32$builder = new builder();33echo $builder->getVersion();

Full Screen

Full Screen

getVersion

Using AI Code Generation

copy

Full Screen

1$builder = new Builder();2echo $builder->getVersion();3{4 public function getVersion()5 {6 return "Builder Class Version 1.0";7 }8}9{10 public function getVersion()11 {12 return "Builder Class Version 2.0";13 }14}15{16 public function getVersion()17 {18 return "Builder Class Version 3.0";19 }20}21{22 public function getVersion()23 {24 return "Builder Class Version 4.0";25 }26}27{28 public function getVersion()29 {30 return "Builder Class Version 5.0";31 }32}33{34 public function getVersion()35 {36 return "Builder Class Version 6.0";37 }38}

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 Atoum automation tests on LambdaTest cloud grid

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

Trigger getVersion code on LambdaTest Cloud Grid

Execute automation tests with getVersion on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

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