laravel-nami-api/tests/TestCase.php

53 lines
1.1 KiB
PHP
Raw Normal View History

2020-06-27 23:45:49 +02:00
<?php
namespace Zoomyboy\LaravelNami\Tests;
2020-06-28 00:25:41 +02:00
use Illuminate\Support\Facades\Config;
2020-06-29 00:30:57 +02:00
use Illuminate\Support\Facades\Http;
2022-02-18 18:29:02 +01:00
use Zoomyboy\LaravelNami\Api;
2021-06-21 22:37:23 +02:00
use Zoomyboy\LaravelNami\Cookies\Cookie;
use Zoomyboy\LaravelNami\Cookies\FakeCookie;
2022-02-18 18:29:02 +01:00
use Zoomyboy\LaravelNami\Nami;
2022-02-10 23:19:31 +01:00
use Zoomyboy\LaravelNami\Providers\NamiServiceProvider;
use Zoomyboy\LaravelNami\Tests\Stub\Member;
2020-06-28 00:25:41 +02:00
2020-06-27 23:45:49 +02:00
class TestCase extends \Orchestra\Testbench\TestCase
{
2020-06-28 00:25:41 +02:00
2021-06-21 22:37:23 +02:00
public function setUp(): void {
parent::setUp();
2022-02-18 17:56:04 +01:00
$this->clearCookies();
2021-06-21 22:37:23 +02:00
}
2020-06-28 00:25:41 +02:00
protected function getPackageProviders($app)
{
return [ NamiServiceProvider::class ];
}
2021-06-18 23:36:22 +02:00
public function getAnnotations(): array {
return [];
}
2022-02-10 23:19:31 +01:00
public function fakeJson(string $file, array $data = []): string {
ob_start();
include(__DIR__.'/json/'.$file);
return ob_get_clean();
2020-06-29 00:30:57 +02:00
}
2022-02-18 18:29:02 +01:00
public function login(): Api
{
touch (__DIR__.'/../.cookies/'.time().'.txt');
return Nami::login(123, 'secret');
2020-06-29 23:12:16 +02:00
}
2022-02-18 17:56:04 +01:00
private function clearCookies(): void
{
foreach (glob(__DIR__.'/../.cookies/*') as $file) {
unlink($file);
}
}
2020-06-27 23:45:49 +02:00
}