Files
firefly-iii/tests/Api/V1/Controllers/UserControllerTest.php

73 lines
2.1 KiB
PHP
Raw Normal View History

2018-03-03 08:12:18 +01:00
<?php
/**
* UserControllerTest.php
2020-02-16 13:59:55 +01:00
* Copyright (c) 2019 james@firefly-iii.org
2018-03-03 08:12:18 +01:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2018-03-03 08:12:18 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2018-03-03 08:12:18 +01:00
*
* This program is distributed in the hope that it will be useful,
2018-03-03 08:12:18 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2018-03-03 08:12:18 +01:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-03-03 08:12:18 +01:00
*/
declare(strict_types=1);
namespace Tests\Api\V1\Controllers;
2020-07-31 06:53:48 +02:00
use Faker\Factory;
2018-03-03 10:15:39 +01:00
use FireflyIII\Repositories\User\UserRepositoryInterface;
2018-12-16 13:55:19 +01:00
use FireflyIII\Transformers\UserTransformer;
2018-03-03 10:15:39 +01:00
use Laravel\Passport\Passport;
use Log;
2018-07-13 06:12:39 +02:00
use Mockery;
2018-03-03 08:12:18 +01:00
use Tests\TestCase;
/**
* Class UserControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
2018-03-03 08:12:18 +01:00
*/
class UserControllerTest extends TestCase
{
2018-03-03 10:15:39 +01:00
/**
*
*/
2018-09-02 20:27:26 +02:00
public function setUp(): void
2018-03-03 10:15:39 +01:00
{
parent::setUp();
Passport::actingAs($this->user());
2020-03-15 15:32:09 +01:00
$this->mockDefaultConfiguration();
2018-03-03 10:15:39 +01:00
}
/**
2018-07-01 09:27:22 +02:00
* Store new user.
*
* @covers \FireflyIII\Api\V1\Controllers\UserController
* @covers \FireflyIII\Api\V1\Requests\UserStoreRequest
2018-03-03 10:15:39 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testStoreBasic(): void
2018-03-03 10:15:39 +01:00
{
2020-07-31 06:53:48 +02:00
Log::info(sprintf('Now in test %s.', __METHOD__));
// random user
$faker = Factory::create();
$data = ['email' => $faker->email,];
2018-03-03 10:15:39 +01:00
2020-07-31 06:53:48 +02:00
// test API
$response = $this->post(route('api.v1.users.store'), $data, ['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
$response->assertStatus(200);
}
2018-03-04 15:14:29 +01:00
}