Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 5, 2024
1 parent 5cb58e2 commit f66f9c0
Show file tree
Hide file tree
Showing 35 changed files with 53 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/Endpoints/BalanceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Mollie\Api\Resources\BalanceCollection;
use Mollie\Api\Resources\LazyCollection;

class BalanceEndpoint extends CollectionRestEndpoint
class BalanceEndpoint extends EndpointCollection
{
const string RESOURCE_ID_PREFIX = 'bal_';
const RESOURCE_ID_PREFIX = 'bal_';

protected string $resourcePath = "balances";

Expand Down
18 changes: 10 additions & 8 deletions src/Endpoints/BalanceReportEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BalanceReportEndpoint extends RestEndpoint
/**
* @inheritDoc
*/
protected function getResourceObject()
protected function getResourceObject(): BalanceReport
{
return new BalanceReport($this->client);
}
Expand All @@ -25,10 +25,11 @@ protected function getResourceObject()
*
* @param string $balanceId
* @param array $parameters
* @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource
*
* @return BalanceReport
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function getForId(string $balanceId, array $parameters = [])
public function getForId(string $balanceId, array $parameters = []): BalanceReport
{
$this->parentId = $balanceId;

Expand All @@ -45,10 +46,11 @@ public function getForId(string $balanceId, array $parameters = [])
* This is the balance of your account’s primary currency, where all payments are settled to by default.
*
* @param array $parameters
* @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource
*
* @return BalanceReport
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function getForPrimary(array $parameters = [])
public function getForPrimary(array $parameters = []): BalanceReport
{
return $this->getForId("primary", $parameters);
}
Expand All @@ -57,12 +59,12 @@ public function getForPrimary(array $parameters = [])
/**
* Retrieve a balance report for the provided balance resource and parameters.
*
* @param \Mollie\Api\Resources\Balance $balance
* @param Balance $balance
* @param array $parameters
* @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource
* @return BalanceReport
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function getFor(Balance $balance, array $parameters = [])
public function getFor(Balance $balance, array $parameters = []): BalanceReport
{
return $this->getForId($balance->id, $parameters);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Endpoints/BalanceTransactionEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Mollie\Api\Resources\BalanceTransactionCollection;
use Mollie\Api\Resources\LazyCollection;

class BalanceTransactionEndpoint extends CollectionRestEndpoint
class BalanceTransactionEndpoint extends EndpointCollection
{
const string RESOURCE_ID_PREFIX = 'baltr_';
const RESOURCE_ID_PREFIX = 'baltr_';

protected string $resourcePath = "balances_transactions";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;

class ChargebackEndpoint extends CollectionRestEndpoint
class ChargebackEndpoint extends EndpointCollection
{
protected string $resourcePath = "chargebacks";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ClientEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\ClientCollection;
use Mollie\Api\Resources\LazyCollection;

class ClientEndpoint extends CollectionRestEndpoint
class ClientEndpoint extends EndpointCollection
{
protected string $resourcePath = "clients";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/CustomerEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\CustomerCollection;
use Mollie\Api\Resources\LazyCollection;

class CustomerEndpoint extends CollectionRestEndpoint
class CustomerEndpoint extends EndpointCollection
{
protected string $resourcePath = "customers";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/CustomerPaymentsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;

class CustomerPaymentsEndpoint extends CollectionRestEndpoint
class CustomerPaymentsEndpoint extends EndpointCollection
{
protected string $resourcePath = "customers_payments";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\ResourceFactory;

abstract class CollectionRestEndpoint extends RestEndpoint
abstract class EndpointCollection extends RestEndpoint
{
/**
* Get a collection of objects from the REST API.
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/InvoiceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\InvoiceCollection;
use Mollie\Api\Resources\LazyCollection;

class InvoiceEndpoint extends CollectionRestEndpoint
class InvoiceEndpoint extends EndpointCollection
{
protected string $resourcePath = "invoices";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/MandateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Mandate;
use Mollie\Api\Resources\MandateCollection;

class MandateEndpoint extends CollectionRestEndpoint
class MandateEndpoint extends EndpointCollection
{
protected string $resourcePath = "customers_mandates";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/MethodEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\MethodCollection;
use Mollie\Api\Resources\ResourceFactory;

class MethodEndpoint extends CollectionRestEndpoint
class MethodEndpoint extends EndpointCollection
{
protected string $resourcePath = "methods";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/OnboardingEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function get(): Onboarding
*/
public function submit(array $parameters = []): void
{
return $this->create($parameters, []);
$this->create($parameters, []);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/OrderEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\OrderCollection;

class OrderEndpoint extends CollectionRestEndpoint
class OrderEndpoint extends EndpointCollection
{
protected string $resourcePath = "orders";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/OrderLineEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\OrderLineCollection;
use Mollie\Api\Resources\ResourceFactory;

class OrderLineEndpoint extends CollectionRestEndpoint
class OrderLineEndpoint extends EndpointCollection
{
protected string $resourcePath = "orders_lines";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/OrderPaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;

class OrderPaymentEndpoint extends CollectionRestEndpoint
class OrderPaymentEndpoint extends EndpointCollection
{
protected string $resourcePath = "orders_payments";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/OrderRefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mollie\Api\Resources\Refund;
use Mollie\Api\Resources\RefundCollection;

class OrderRefundEndpoint extends CollectionRestEndpoint
class OrderRefundEndpoint extends EndpointCollection
{
protected string $resourcePath = "orders_refunds";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentCaptureEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;

class PaymentCaptureEndpoint extends CollectionRestEndpoint
class PaymentCaptureEndpoint extends EndpointCollection
{
protected string $resourcePath = "payments_captures";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;

class PaymentChargebackEndpoint extends CollectionRestEndpoint
class PaymentChargebackEndpoint extends EndpointCollection
{
protected string $resourcePath = "payments_chargebacks";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\PaymentCollection;
use Mollie\Api\Resources\Refund;

class PaymentEndpoint extends CollectionRestEndpoint
class PaymentEndpoint extends EndpointCollection
{
protected string $resourcePath = "payments";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentLinkEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\PaymentLink;
use Mollie\Api\Resources\PaymentLinkCollection;

class PaymentLinkEndpoint extends CollectionRestEndpoint
class PaymentLinkEndpoint extends EndpointCollection
{
protected string $resourcePath = "payment-links";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentRefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Refund;
use Mollie\Api\Resources\RefundCollection;

class PaymentRefundEndpoint extends CollectionRestEndpoint
class PaymentRefundEndpoint extends EndpointCollection
{
protected string $resourcePath = "payments_refunds";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PermissionEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mollie\Api\Resources\Permission;
use Mollie\Api\Resources\PermissionCollection;

class PermissionEndpoint extends CollectionRestEndpoint
class PermissionEndpoint extends EndpointCollection
{
protected string $resourcePath = "permissions";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ProfileEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\Profile;
use Mollie\Api\Resources\ProfileCollection;

class ProfileEndpoint extends CollectionRestEndpoint
class ProfileEndpoint extends EndpointCollection
{
protected string $resourcePath = "profiles";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ProfileMethodEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Profile;
use Mollie\Api\Resources\ResourceFactory;

class ProfileMethodEndpoint extends CollectionRestEndpoint
class ProfileMethodEndpoint extends EndpointCollection
{
protected string $resourcePath = "profiles_methods";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/RefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Refund;
use Mollie\Api\Resources\RefundCollection;

class RefundEndpoint extends CollectionRestEndpoint
class RefundEndpoint extends EndpointCollection
{
protected string $resourcePath = "refunds";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementCaptureEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\CaptureCollection;
use Mollie\Api\Resources\LazyCollection;

class SettlementCaptureEndpoint extends CollectionRestEndpoint
class SettlementCaptureEndpoint extends EndpointCollection
{
protected string $resourcePath = "settlements_captures";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;

class SettlementChargebackEndpoint extends CollectionRestEndpoint
class SettlementChargebackEndpoint extends EndpointCollection
{
protected string $resourcePath = "settlements_chargebacks";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementPaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;

class SettlementPaymentEndpoint extends CollectionRestEndpoint
class SettlementPaymentEndpoint extends EndpointCollection
{
protected string $resourcePath = "settlements_payments";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementRefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\Refund;
use Mollie\Api\Resources\RefundCollection;

class SettlementRefundEndpoint extends CollectionRestEndpoint
class SettlementRefundEndpoint extends EndpointCollection
{
protected string $resourcePath = "settlements_refunds";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Settlement;
use Mollie\Api\Resources\SettlementCollection;

class SettlementsEndpoint extends CollectionRestEndpoint
class SettlementsEndpoint extends EndpointCollection
{
protected string $resourcePath = "settlements";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ShipmentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Shipment;
use Mollie\Api\Resources\ShipmentCollection;

class ShipmentEndpoint extends CollectionRestEndpoint
class ShipmentEndpoint extends EndpointCollection
{
protected string $resourcePath = "orders_shipments";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SubscriptionEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\Subscription;
use Mollie\Api\Resources\SubscriptionCollection;

class SubscriptionEndpoint extends CollectionRestEndpoint
class SubscriptionEndpoint extends EndpointCollection
{
protected string $resourcePath = "customers_subscriptions";

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/TerminalEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mollie\Api\Resources\Terminal;
use Mollie\Api\Resources\TerminalCollection;

class TerminalEndpoint extends CollectionRestEndpoint
class TerminalEndpoint extends EndpointCollection
{
protected string $resourcePath = "terminals";

Expand Down
10 changes: 5 additions & 5 deletions src/Resources/ResourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public static function createFromApiResult(object $apiResult, BaseResource $reso
public static function createBaseResourceCollection(
MollieApiClient $client,
string $resourceClass,
array $data,
object $_links = null,
string $resourceCollectionClass = null
?array $data = null,
?object $_links = null,
?string $resourceCollectionClass = null
): BaseCollection {
$resourceCollectionClass = $resourceCollectionClass ?: $resourceClass . 'Collection';
$data = $data ?: [];
Expand All @@ -61,8 +61,8 @@ public static function createCursorResourceCollection(
MollieApiClient $client,
array $input,
string $resourceClass,
object $_links = null,
string $resourceCollectionClass = null
?object $_links = null,
?string $resourceCollectionClass = null
): CursorCollection {
if (null === $resourceCollectionClass) {
$resourceCollectionClass = $resourceClass . 'Collection';
Expand Down
5 changes: 4 additions & 1 deletion tests/Mollie/API/Endpoints/OrderLineEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public function testCancelLinesRequiresLinesArray()
$this->guzzleClient = $this->createMock(Client::class);
$this->apiClient = new MollieApiClient($this->guzzleClient);

$this->apiClient->orderLines->cancelFor(new Order($this->apiClient), []);
$order = new Order($this->apiClient);
$order->id = 'ord_pbjz8x';

$this->apiClient->orderLines->cancelFor($order, []);
}

public function testUpdateMultipleOrderLines()
Expand Down

0 comments on commit f66f9c0

Please sign in to comment.