Skip to content

Commit 749eaff

Browse files
authoredJul 16, 2020
Merge pull request #38 from packagist/t/customer-add-minimum-stability
Vendor: add option to limit package versions by stability
2 parents 42fa918 + 480d247 commit 749eaff

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
 

‎README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Returns a single customer.
191191
```php
192192
$customer = $client->customers()->create('New customer name');
193193
// or
194-
$customer = $client->customers()->create('New customer name', false, 'customer-url-name');
194+
$customer = $client->customers()->create('New customer name', false, 'customer-url-name', 'beta');
195195
```
196196
Returns the customer.
197197

@@ -202,6 +202,7 @@ $customerData = [
202202
'name' => $name,
203203
'urlName' => 'customer',
204204
'accessToVersionControlSource' => false,
205+
'minimumAccessibleStability' => 'beta',
205206
];
206207
$customer = $client->customers()->edit($customerId, $customerData);
207208
```
@@ -240,6 +241,7 @@ $packages = [
240241
'name' => 'acme-website/package',
241242
'versionConstraint' => '^1.0 | ^2.0', // optional version constraint to limit updates the customer receives
242243
'expirationDate' => (new \DateTime())->add(new \DateInterval('P1Y'))->format('c'), // optional expiration date to limit updates the customer receives
244+
'minimumAccessibleStability' => 'beta', // optional stability to restrict customers to specific package version stabilities like alpha, beta, or RC
243245
],
244246
];
245247
$packages = $client->customers()->addOrEditPackages($customerId, $packages);

‎src/Api/Customers.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ public function show($customerIdOrUrlName)
2424
return $this->get(sprintf('/customers/%s/', $customerIdOrUrlName));
2525
}
2626

27-
public function create($name, $accessToVersionControlSource = false, $urlName = null)
27+
public function create($name, $accessToVersionControlSource = false, $urlName = null, $minimumAccessibleStability = null)
2828
{
2929
$parameters = [
3030
'name' => $name,
3131
'accessToVersionControlSource' => $accessToVersionControlSource,
32+
'minimumAccessibleStability' => $minimumAccessibleStability,
3233
];
3334
if ($urlName) {
3435
$parameters['urlName'] = $urlName;

‎tests/Api/CustomersTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ public function testCreate()
5757
'type' => 'composer-repo',
5858
'name' => $name = 'Customer',
5959
'accessToVersionControlSource' => false,
60+
'minimumAccessibleStability' => 'dev',
6061
],
6162
];
6263

6364
/** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
6465
$api = $this->getApiMock();
6566
$api->expects($this->once())
6667
->method('post')
67-
->with($this->equalTo('/customers/'), $this->equalTo(['name' => $name, 'accessToVersionControlSource' => false]))
68+
->with($this->equalTo('/customers/'), $this->equalTo(['name' => $name, 'accessToVersionControlSource' => false, 'minimumAccessibleStability' => null]))
6869
->willReturn($expected);
6970

7071
$this->assertSame($expected, $api->create($name));
@@ -78,17 +79,18 @@ public function testCreateAllParameters()
7879
'type' => 'composer-repo',
7980
'name' => $name = 'Customer',
8081
'accessToVersionControlSource' => false,
82+
'minimumAccessibleStability' => 'beta'
8183
],
8284
];
8385

8486
/** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
8587
$api = $this->getApiMock();
8688
$api->expects($this->once())
8789
->method('post')
88-
->with($this->equalTo('/customers/'), $this->equalTo(['name' => $name, 'accessToVersionControlSource' => true, 'urlName' => 'url-name']))
90+
->with($this->equalTo('/customers/'), $this->equalTo(['name' => $name, 'accessToVersionControlSource' => true, 'urlName' => 'url-name', 'minimumAccessibleStability' => 'beta']))
8991
->willReturn($expected);
9092

91-
$this->assertSame($expected, $api->create($name, true, 'url-name'));
93+
$this->assertSame($expected, $api->create($name, true, 'url-name', 'beta'));
9294
}
9395

9496
public function tesEdit()
@@ -100,13 +102,15 @@ public function tesEdit()
100102
'name' => $name = 'Customer',
101103
'urlName' => 'customer',
102104
'accessToVersionControlSource' => false,
105+
'minimumAccessibleStability' => 'dev',
103106
],
104107
];
105108

106109
$customer = [
107110
'name' => $name,
108111
'urlName' => 'customer',
109112
'accessToVersionControlSource' => false,
113+
'minimumAccessibleStability' => null,
110114
];
111115

112116
/** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */

0 commit comments

Comments
 (0)