--wip-- [skip ci]
This commit is contained in:
parent
7b336882d9
commit
83f17eb25b
|
@ -13,7 +13,8 @@
|
|||
"guzzlehttp/guzzle": "^6.3.1|^7.0",
|
||||
"laravel/framework": "^9.0",
|
||||
"laravel/ui": "^3.4",
|
||||
"spatie/laravel-data": "^2.0"
|
||||
"spatie/laravel-data": "^2.0",
|
||||
"worksome/request-factories": "^2.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "346a5a2a97f685b2c63ce6fb3d29b2be",
|
||||
"content-hash": "f5d576e024f1b8750894ea89e5c69a68",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
|
@ -5114,6 +5114,80 @@
|
|||
"source": "https://github.com/webmozarts/assert/tree/1.10.0"
|
||||
},
|
||||
"time": "2021-03-09T10:59:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "worksome/request-factories",
|
||||
"version": "v2.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/worksome/request-factories.git",
|
||||
"reference": "59016791b5fb9cf77eb777bfaeef7b47d21ebcdc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/worksome/request-factories/zipball/59016791b5fb9cf77eb777bfaeef7b47d21ebcdc",
|
||||
"reference": "59016791b5fb9cf77eb777bfaeef7b47d21ebcdc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "^8.0 || ^9.0",
|
||||
"php": "^8.0 || ^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nunomaduro/collision": "^5.10 || ^6.0",
|
||||
"nunomaduro/larastan": "^1.0 || ^2.0",
|
||||
"orchestra/testbench": "^6.22 || ^7.0",
|
||||
"pestphp/pest": "^1.21",
|
||||
"pestphp/pest-plugin-laravel": "^1.1",
|
||||
"worksome/coding-style": "0.17.0",
|
||||
"worksome/pest-plugin-silence": "^0.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Worksome\\RequestFactories\\RequestFactoriesServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/PestAutoload.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Worksome\\RequestFactories\\": "src",
|
||||
"Worksome\\RequestFactories\\Database\\Factories\\": "database/factories"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "luke",
|
||||
"email": "lukeraymonddowning@gmail.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Test Form Requests in Laravel without all of the boilerplate.",
|
||||
"homepage": "https://github.com/worksome/request-factories",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"request-factories",
|
||||
"worksome"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/worksome/request-factories/issues",
|
||||
"source": "https://github.com/worksome/request-factories/tree/v2.5.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/worksome",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-09-15T11:48:41+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Factories;
|
||||
|
||||
use GuzzleHttp\Promise\FulfilledPromise;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Worksome\RequestFactories\RequestFactory;
|
||||
|
||||
class MemberRequestFactory extends RequestFactory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'vorname' => $this->faker->firstName,
|
||||
'nachname' => $this->faker->lastName,
|
||||
'nickname' => $this->faker->firstName,
|
||||
];
|
||||
}
|
||||
|
||||
public function toSingleHttp(): FulfilledPromise
|
||||
{
|
||||
return Http::response($this->create(), 200);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zoomyboy\LaravelNami\Tests;
|
||||
|
||||
use Spatie\LaravelData\LaravelDataServiceProvider;
|
||||
use Worksome\RequestFactories\RequestFactoriesServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
||||
|
@ -20,7 +21,7 @@ class TestCase extends \Orchestra\Testbench\TestCase
|
|||
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [LaravelDataServiceProvider::class, NamiServiceProvider::class];
|
||||
return [RequestFactoriesServiceProvider::class, LaravelDataServiceProvider::class, NamiServiceProvider::class];
|
||||
}
|
||||
|
||||
public function getAnnotations(): array
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zoomyboy\LaravelNami\Tests\Unit\Member;
|
|||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\Tests\Factories\MemberRequestFactory;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PullTest extends TestCase
|
||||
|
@ -81,18 +82,34 @@ class PullTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
public function testGetASingleMember(array $input, array $check): void
|
||||
public function testGetASingleMember(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json', ['data' => $input]), 200),
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => MemberRequestFactory::new()->state([
|
||||
'vorname' => 'Max',
|
||||
'nachname' => 'Nach',
|
||||
'spitzname' => 'spitz1',
|
||||
])->toSingleHttp(),
|
||||
]);
|
||||
|
||||
$member = $this->login()->member(103, 16);
|
||||
|
||||
$this->assertEquals('Max', $member->firstname);
|
||||
$this->assertEquals('Nach', $member->lastname);
|
||||
$this->assertEquals('spitz1', $member->nickname);
|
||||
}
|
||||
|
||||
Http::assertSentCount(1);
|
||||
public function testGetASingleMemberWithEmptyNames(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => MemberRequestFactory::new()->withEmptyNames()->toSingleHttp(),
|
||||
]);
|
||||
|
||||
$member = $this->login()->member(103, 16);
|
||||
|
||||
$this->assertNull($member->firstname);
|
||||
$this->assertNull($member->lastname);
|
||||
$this->assertNull($member->nickname);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue