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

93 lines
2.8 KiB
PHP
Raw Normal View History

2018-02-17 14:46:12 +01:00
<?php
/**
* AboutControllerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Api\V1\Controllers;
2018-12-16 13:55:19 +01:00
use FireflyIII\Transformers\UserTransformer;
2018-02-17 14:46:12 +01:00
use Laravel\Passport\Passport;
2018-02-28 20:18:47 +01:00
use Log;
use Tests\TestCase;
2018-02-17 14:46:12 +01:00
/**
2018-12-16 13:55:19 +01:00
* Class AboutControllerTest.
2018-02-17 14:46:12 +01:00
*/
class AboutControllerTest extends TestCase
{
/**
* Set up test
*/
2018-09-02 20:27:26 +02:00
public function setUp(): void
2018-02-17 14:46:12 +01:00
{
parent::setUp();
Passport::actingAs($this->user());
2019-04-09 20:05:20 +02:00
Log::info(sprintf('Now in %s.', get_class($this)));
2018-02-17 14:46:12 +01:00
}
/**
* Test the about endpoint
*
2018-07-01 09:27:22 +02:00
* @covers \FireflyIII\Api\V1\Controllers\AboutController
2018-02-17 14:46:12 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testAbout(): void
2018-02-17 14:46:12 +01:00
{
2018-12-10 21:45:44 +01:00
$search = ['~', '#'];
$replace = ['\~', '# '];
$phpVersion = str_replace($search, $replace, PHP_VERSION);
$phpOs = str_replace($search, $replace, PHP_OS);
$response = $this->get(route('api.v1.about.index'));
2018-02-17 14:46:12 +01:00
$response->assertStatus(200);
$response->assertJson(
['data' => [
2018-12-10 21:45:44 +01:00
'version' => config('firefly.version'),
'api_version' => config('firefly.api_version'),
'php_version' => $phpVersion,
'os' => $phpOs,
'driver' => 'sqlite',
2018-02-17 14:46:12 +01:00
]]
);
}
/**
* Test user end point
2018-02-18 10:31:15 +01:00
*
2018-07-01 09:27:22 +02:00
* @covers \FireflyIII\Api\V1\Controllers\AboutController
2018-02-17 14:46:12 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testUser(): void
2018-02-17 14:46:12 +01:00
{
2018-12-16 13:55:19 +01:00
$transformer = $this->mock(UserTransformer::class);
// mock calls to transformer:
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
2018-12-10 21:45:44 +01:00
$response = $this->get(route('api.v1.about.user'));
2018-02-17 14:46:12 +01:00
$response->assertStatus(200);
}
2018-03-04 15:14:29 +01:00
}