Skip to content

Commit 88bc9e1

Browse files
authored
Merge pull request #8 from coderflexx/fix/broken-tests
FIX - Broken Unit Tests.
2 parents 28b08f2 + ef3a503 commit 88bc9e1

File tree

11 files changed

+55
-40
lines changed

11 files changed

+55
-40
lines changed

.github/workflows/run-tests.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ jobs:
2222
matrix:
2323
os: [ubuntu-latest, windows-latest]
2424
php: [8.4, 8.3]
25-
laravel: [12.*, 11.*, 10.*]
25+
laravel: [12.*, 11.*]
2626
stability: [prefer-lowest, prefer-stable]
2727
include:
2828
- laravel: 12.*
2929
testbench: 10.*
3030
- laravel: 11.*
3131
testbench: 9.*
32+
exclude:
3233
- laravel: 10.*
33-
testbench: 8.*
34-
34+
php: 8.4
35+
3536

3637
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
3738

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/coderflexx/laravel-sendy.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-sendy)
44
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/coderflexx/laravel-sendy/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/coderflexx/laravel-sendy/actions?query=workflow%3Arun-tests+branch%3Amain)
55
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/coderflexx/laravel-sendy/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/coderflexx/laravel-sendy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
6-
[![Total Downloads](https://img.shields.io/packagist/dt/coderflexx/laravel-sendy.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-sendy)
76

87
---
98

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^8.4",
19+
"php": "^8.3",
2020
"ext-curl": "*",
2121
"ext-json": "*",
2222
"illuminate/contracts": "^10.0||^11.0||^12.0",

phpstan.neon.dist

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ parameters:
55
level: 5
66
paths:
77
- src
8-
- config
9-
- database
108
tmpDir: build/phpstan
119
checkOctaneCompatibility: true
1210
checkModelProperties: true

src/Concerns/InteractsWithHttpRequests.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Coderflex\LaravelSendy\Exceptions\InvalidApiKeyException;
66
use Coderflex\LaravelSendy\Exceptions\InvalidApiUrlException;
77
use Exception;
8+
use Illuminate\Http\Client\Response;
89
use Illuminate\Support\Facades\Http;
910

1011
/**
@@ -16,7 +17,7 @@
1617
*/
1718
trait InteractsWithHttpRequests
1819
{
19-
public function __call(string $function, array $args): mixed
20+
public function __call(string $function, array $args): Response
2021
{
2122
$options = ['get', 'post', 'put', 'delete', 'patch'];
2223
$path = $args[0] ?? null;
@@ -65,7 +66,7 @@ protected function sendRequest(string $type, string $request, array $data = [],
6566
$client = Http::withHeaders(array_merge([
6667
'Content-Type' => 'application/json',
6768
'Accept' => 'application/json',
68-
], $headers ?? []));
69+
], $headers));
6970

7071
return $async
7172
? $client->async()->{$type}($url, $payload)

src/Facades/Sendy.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* @method static \Coderflex\LaravelSendy\Resources\Lists lists()
1212
* @method static \Coderflex\LaravelSendy\Resources\Brands brands()
1313
* @method static \Coderflex\LaravelSendy\Resources\Campaigns campaigns()
14+
* @method static mixed post(string $endpoint, array $data, bool $async = false)
1415
*/
1516
class Sendy extends Facade
1617
{

src/Resources/Brands.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
namespace Coderflex\LaravelSendy\Resources;
44

5-
use Coderflex\LaravelSendy\Facades\Sendy;
5+
use Coderflex\LaravelSendy\Sendy;
6+
use Illuminate\Http\Client\Response;
67

78
class Brands
89
{
9-
public function get()
10+
public function __construct(
11+
protected Sendy $sendy
12+
) {}
13+
14+
public function get(): Response
1015
{
11-
return Sendy::post('/api/brands/get-brands.php');
16+
return $this->sendy->post('/api/brands/get-brands.php');
1217
}
1318
}

src/Resources/Campaigns.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@
33
namespace Coderflex\LaravelSendy\Resources;
44

55
use Coderflex\LaravelSendy\DTOs\Campaigns\CampaignDTO;
6-
use Coderflex\LaravelSendy\Facades\Sendy;
6+
use Coderflex\LaravelSendy\Sendy;
7+
use Illuminate\Http\Client\Response;
78

89
class Campaigns
910
{
10-
public function create(array $data, bool $async = false)
11+
public function __construct(
12+
protected Sendy $sendy
13+
) {}
14+
15+
public function create(array $data, bool $async = false): Response
1116
{
1217
$data = CampaignDTO::validate($data);
1318

14-
return Sendy::post('/api/campaigns/create.php', $data, $async);
19+
return $this->sendy->post('/api/campaigns/create.php', $data, $async);
1520
}
1621

17-
public function createAndSend(array $data, bool $async = false)
22+
public function createAndSend(array $data, bool $async = false): Response
1823
{
1924
$data = array_merge($data, [
2025
'send_compaign' => 1,
2126
]);
2227

23-
return Sendy::post('/api/campaigns/create.php', $data, $async);
28+
return $this->sendy->post('/api/campaigns/create.php', $data, $async);
2429
}
2530
}

src/Resources/Lists.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
namespace Coderflex\LaravelSendy\Resources;
44

55
use Coderflex\LaravelSendy\DTOs\Lists\ListsDTO;
6-
use Coderflex\LaravelSendy\Facades\Sendy;
6+
use Coderflex\LaravelSendy\Sendy;
7+
use Illuminate\Http\Client\Response;
78

89
class Lists
910
{
10-
/**
11-
* Get all lists for a specific brand.
12-
*
13-
* @return array
14-
*/
15-
public function get(array $data, bool $async = false)
11+
public function __construct(
12+
protected Sendy $sendy
13+
) {}
14+
15+
public function get(array $data, bool $async = false): Response
1616
{
1717
$data = ListsDTO::validate($data);
1818

19-
return Sendy::post('/api/lists/get-lists.php', $data, $async);
19+
return $this->sendy->post('/api/lists/get-lists.php', $data, $async);
2020
}
2121
}

src/Resources/Subscribers.php

+16-11
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,49 @@
66
use Coderflex\LaravelSendy\DTOs\Subscribers\SubscribeDTO;
77
use Coderflex\LaravelSendy\DTOs\Subscribers\SubscriberStatusDTO;
88
use Coderflex\LaravelSendy\DTOs\Subscribers\UnsubscribeDTO;
9-
use Coderflex\LaravelSendy\Facades\Sendy;
9+
use Coderflex\LaravelSendy\Sendy;
10+
use Illuminate\Http\Client\Response;
1011

1112
class Subscribers
1213
{
13-
public function subscribe(array $data, bool $async = false)
14+
public function __construct(
15+
protected Sendy $sendy
16+
) {}
17+
18+
public function subscribe(array $data, bool $async = false): Response
1419
{
1520
$data = SubscribeDTO::validate($data);
1621

17-
return Sendy::post('subscribe', $data, $async);
22+
return $this->sendy->post('subscribe', $data, $async);
1823
}
1924

20-
public function unsubscribe(array $data, bool $async = false)
25+
public function unsubscribe(array $data, bool $async = false): Response
2126
{
2227
$data = UnsubscribeDTO::validate($data);
2328

24-
return Sendy::post('api/subscribers/unsubscribe.php', $data, $async);
29+
return $this->sendy->post('api/subscribers/unsubscribe.php', $data, $async);
2530
}
2631

27-
public function delete(array $data, bool $async = false)
32+
public function delete(array $data, bool $async = false): Response
2833
{
2934
$data = DeleteSubscriberDTO::validate($data);
3035

31-
return Sendy::post('api/subscribers/delete.php', $data, $async);
36+
return $this->sendy->post('api/subscribers/delete.php', $data, $async);
3237
}
3338

34-
public function status(array $data, bool $async = false)
39+
public function status(array $data, bool $async = false): Response
3540
{
3641
$data = SubscriberStatusDTO::validate($data);
3742

38-
return Sendy::post('api/subscribers/subscription-status.php', $data, $async);
43+
return $this->sendy->post('api/subscribers/subscription-status.php', $data, $async);
3944
}
4045

41-
public function count(int $listId, bool $async = false)
46+
public function count(int $listId, bool $async = false): Response
4247
{
4348
$data = [
4449
'list_id' => $listId,
4550
];
4651

47-
return Sendy::post('api/subscribers/subscriber-count.php', $data, $async);
52+
return $this->sendy->post('api/subscribers/subscriber-count.php', $data, $async);
4853
}
4954
}

src/Sendy.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ class Sendy
1010

1111
public function subscribers(): Resources\Subscribers
1212
{
13-
return new Resources\Subscribers;
13+
return new Resources\Subscribers($this);
1414
}
1515

1616
public function lists(): Resources\Lists
1717
{
18-
return new Resources\Lists;
18+
return new Resources\Lists($this);
1919
}
2020

2121
public function brands(): Resources\Brands
2222
{
23-
return new Resources\Brands;
23+
return new Resources\Brands($this);
2424
}
2525

2626
public function campaigns(): Resources\Campaigns
2727
{
28-
return new Resources\Campaigns;
28+
return new Resources\Campaigns($this);
2929
}
3030
}

0 commit comments

Comments
 (0)