Пример #1
0
 /**
  * @test
  */
 public function it_deletes_a_feature()
 {
     $wps = new Sdk();
     $wps->addMockResults([new Response(200, [], json_encode($wps->featureResponse(3))), new Response(204, [])]);
     $feature = $wps->feature()->find(3);
     $success = $feature->delete();
     $this->assertEquals(['/features/3/', '/features/3/'], $wps->getRequestUris());
     $this->assertEquals(true, $success);
 }
Пример #2
0
 /**
  * @test
  */
 public function it_gets_imagestyles_of_an_image()
 {
     $wps = new Sdk();
     $wps->addMockResults([new Response(200, [], json_encode($wps->imageResponse(1))), new Response(200, [], json_encode($wps->imagestylesResponse()))]);
     $image = $wps->image()->find(1);
     $this->assertContainsOnlyInstancesOf(Wps\Models\Imagestyle::class, $image->imagestyles);
     $this->assertEquals(['/images/1/', '/images/1/imagestyles/'], $wps->getRequestUris());
 }
Пример #3
0
 /**
  * @test
  */
 public function it_syncs_blocks_for_a_product_on_a_site()
 {
     $wps = new Sdk();
     $response = $wps->blocksResponse();
     $response['data'] = array_reverse($response['data']);
     $wps->addMockResults([new Response(200, [], json_encode($wps->siteResponse(1))), new Response(200, [], json_encode($wps->productResponse(1))), new Response(200, [], json_encode($response))]);
     $site = $wps->site()->find(1);
     $product = $site->products(1);
     $product->blocks()->sync([2, 1]);
     $keys = $product->blocks->map(function ($item, $key) {
         return $item->getKey();
     });
     $this->assertEquals(['/sites/1/', '/products/1/', '/sites/1/products/1/blocks/'], $wps->getRequestUris());
     $this->assertEquals([null, null, '[{"id":2},{"id":1}]'], $wps->getRequestBodies());
     $this->assertContainsOnlyInstancesOf(Wps\Models\Block::class, $product->blocks);
     $this->assertEquals([2, 1], $keys->toArray());
 }
Пример #4
0
 /**
  * @test
  */
 public function it_gets_the_tags_from_a_product()
 {
     $wps = new Sdk();
     $wps->addMockResults([new Response(200, [], json_encode($wps->productResponse(1))), new Response(200, [], json_encode($wps->tagsResponse()))]);
     $product = $wps->product()->find(1);
     $this->assertContainsOnlyInstancesOf(Wps\Models\Tag::class, $product->tags);
     $this->assertEquals(['/products/1/', '/products/1/tags/'], $wps->getRequestUris());
 }