From cd19e86141b8f028e862028db804ec157b025110 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 31 Jul 2020 06:53:48 +0200 Subject: [PATCH] Clean up test code, prep for merge. --- phpunit.coverage.specific.xml | 63 ------------------ phpunit.coverage.xml | 64 ------------------- phpunit.xml | 2 + .../Chart/CategoryControllerTest.php | 3 - .../Api/V1/Controllers/UserControllerTest.php | 13 ++-- tests/TestCase.php | 13 +--- 6 files changed, 13 insertions(+), 145 deletions(-) delete mode 100644 phpunit.coverage.specific.xml delete mode 100644 phpunit.coverage.xml diff --git a/phpunit.coverage.specific.xml b/phpunit.coverage.specific.xml deleted file mode 100644 index 14ca914b98..0000000000 --- a/phpunit.coverage.specific.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - ./tests/Api - - - ./tests/Unit - - - ./tests/Feature - - - - - ./app - - app/Http/breadcrumbs.php - - - - - - - - - - - - - diff --git a/phpunit.coverage.xml b/phpunit.coverage.xml deleted file mode 100644 index 78a52537ac..0000000000 --- a/phpunit.coverage.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - ./tests/Api - - - ./tests/Unit - - - ./tests/Feature - - - - - ./app - - app/Http/breadcrumbs.php - - - - - - - - - - - - - diff --git a/phpunit.xml b/phpunit.xml index a255c39ab5..3ed2160e50 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -37,12 +37,14 @@ ./tests/Api + diff --git a/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php b/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php index 4805200840..10d8571354 100644 --- a/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php +++ b/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php @@ -29,7 +29,6 @@ use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface; use FireflyIII\Repositories\Category\OperationsRepositoryInterface; use Laravel\Passport\Passport; use Log; -use Tests\Support\TestDataTrait; use Tests\TestCase; /** @@ -40,8 +39,6 @@ use Tests\TestCase; */ class CategoryControllerTest extends TestCase { - use TestDataTrait; - /** * */ diff --git a/tests/Api/V1/Controllers/UserControllerTest.php b/tests/Api/V1/Controllers/UserControllerTest.php index ce2966d070..0c090772eb 100644 --- a/tests/Api/V1/Controllers/UserControllerTest.php +++ b/tests/Api/V1/Controllers/UserControllerTest.php @@ -24,9 +24,9 @@ declare(strict_types=1); namespace Tests\Api\V1\Controllers; +use Faker\Factory; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Transformers\UserTransformer; -use FireflyIII\User; use Laravel\Passport\Passport; use Log; use Mockery; @@ -49,7 +49,6 @@ class UserControllerTest extends TestCase parent::setUp(); Passport::actingAs($this->user()); $this->mockDefaultConfiguration(); - Log::info(sprintf('Now in %s.', get_class($this))); } @@ -61,7 +60,13 @@ class UserControllerTest extends TestCase */ public function testStoreBasic(): void { - $this->assertTrue(true); - } + Log::info(sprintf('Now in test %s.', __METHOD__)); + // random user + $faker = Factory::create(); + $data = ['email' => $faker->email,]; + // test API + $response = $this->post(route('api.v1.users.store'), $data, ['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']); + $response->assertStatus(200); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 610ca27616..c07f2814bb 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -25,6 +25,7 @@ namespace Tests; use FireflyIII\User; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; +use Tests\Traits\CollectsValues; use Tests\Traits\MocksDefaultValues; use Tests\Traits\TestHelpers; @@ -33,7 +34,7 @@ use Tests\Traits\TestHelpers; */ abstract class TestCase extends BaseTestCase { - use CreatesApplication, MocksDefaultValues, TestHelpers; + use CreatesApplication, MocksDefaultValues, TestHelpers, CollectsValues; /** * @return array @@ -50,14 +51,4 @@ abstract class TestCase extends BaseTestCase 'custom range' => ['custom'], ]; } - - /** - * @return User - */ - public function user(): User - { - return User::find(1); - } - - }