Skip to content

Commit c4c0f37

Browse files
committed
add brands test
1 parent 9c46cd1 commit c4c0f37

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Resources/Brands.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class Brands
88
{
99
public function get()
1010
{
11-
return LaravelSendy::get('/api/brands/get-brands.php');
11+
return LaravelSendy::post('/api/brands/get-brands.php');
1212
}
1313
}

tests/Resources/BrandsTest.php

+25
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
11
<?php
2+
3+
use Coderflex\LaravelSendy\Facades\LaravelSendy;
4+
use Illuminate\Support\Facades\Http;
5+
6+
beforeEach(function () {
7+
config([
8+
'laravel-sendy.api_key' => 'test_api_key',
9+
'laravel-sendy.api_url' => 'https://sendy.test/',
10+
]);
11+
});
12+
13+
it('can get subscriber brands', function () {
14+
Http::fake([
15+
'https://sendy.test/api/brands/get-brands.php' => Http::response([123 => 'Brand Name'], 200),
16+
]);
17+
18+
$response = LaravelSendy::brands()->get();
19+
20+
expect($response->json())->toBe([123 => 'Brand Name']);
21+
22+
Http::assertSent(function ($request) {
23+
return $request->url() === 'https://sendy.test/api/brands/get-brands.php' &&
24+
$request['api_key'] === 'test_api_key';
25+
});
26+
});

0 commit comments

Comments
 (0)