|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace PrivatePackagist\ApiClient\Api\Customers; |
| 4 | + |
| 5 | +use PHPUnit\Framework\MockObject\MockObject; |
| 6 | +use PrivatePackagist\ApiClient\Api\ApiTestCase; |
| 7 | + |
| 8 | +class VendorBundlesTest extends ApiTestCase |
| 9 | +{ |
| 10 | + public function testListVendorBundles() |
| 11 | + { |
| 12 | + $expected = [ |
| 13 | + [ |
| 14 | + 'expirationDate' => null, |
| 15 | + 'vendorBundle' => ['id' => 12], |
| 16 | + ], |
| 17 | + ]; |
| 18 | + |
| 19 | + /** @var VendorBundles&MockObject $api */ |
| 20 | + $api = $this->getApiMock(); |
| 21 | + $api->expects($this->once()) |
| 22 | + ->method('get') |
| 23 | + ->with($this->equalTo('/customers/1/vendor-bundles/')) |
| 24 | + ->willReturn($expected); |
| 25 | + |
| 26 | + $this->assertSame($expected, $api->listVendorBundles(1)); |
| 27 | + } |
| 28 | + |
| 29 | + public function testAddOrEditVendorBundle() |
| 30 | + { |
| 31 | + $expected = [ |
| 32 | + 'expirationDate' => null, |
| 33 | + 'vendorBundle' => ['id' => 12], |
| 34 | + ]; |
| 35 | + |
| 36 | + /** @var VendorBundles&MockObject $api */ |
| 37 | + $api = $this->getApiMock(); |
| 38 | + $api->expects($this->once()) |
| 39 | + ->method('post') |
| 40 | + ->with($this->equalTo('/customers/1/vendor-bundles/'), $this->equalTo([ |
| 41 | + 'vendorBundleId' => 12, |
| 42 | + 'expirationDate' => null, |
| 43 | + ])) |
| 44 | + ->willReturn($expected); |
| 45 | + |
| 46 | + $this->assertSame($expected, $api->addOrEditVendorBundle(1, 12)); |
| 47 | + } |
| 48 | + |
| 49 | + public function testRemoveVendorBundle() |
| 50 | + { |
| 51 | + $expected = ''; |
| 52 | + |
| 53 | + /** @var VendorBundles&MockObject $api */ |
| 54 | + $api = $this->getApiMock(); |
| 55 | + $api->expects($this->once()) |
| 56 | + ->method('delete') |
| 57 | + ->with($this->equalTo(sprintf('/customers/1/vendor-bundles/%s/', 12))) |
| 58 | + ->willReturn($expected); |
| 59 | + |
| 60 | + $this->assertSame($expected, $api->removeVendorBundle(1, 12)); |
| 61 | + } |
| 62 | + |
| 63 | + protected function getApiClass() |
| 64 | + { |
| 65 | + return VendorBundles::class; |
| 66 | + } |
| 67 | +} |
0 commit comments