test: Checking for updates and global updating

This commit is contained in:
SychO9 2021-11-24 20:16:25 +01:00
parent 5206e8e1dc
commit 488edaca7a
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,42 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api;
use Flarum\PackageManager\Tests\integration\ChangeComposerConfig;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Illuminate\Support\Arr;
class CheckForUpdatesTest extends TestCase
{
use RefreshComposerSetup, ChangeComposerConfig;
/**
* @test
*/
public function can_check_for_updates()
{
$this->setComposerConfig([
'require' => [
'flarum/core' => '^1.0.0',
'flarum/tags' => '1.0.0',
]
]);
$response = $this->send(
$this->request('POST', '/api/package-manager/check-for-updates', [
'authenticatedAs' => 1,
])
);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['flarum/tags'], Arr::pluck(json_decode((string) $response->getBody(), true)['updates']['installed'], 'name'));
}
}

View File

@ -0,0 +1,32 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
class GlobalUpdateTest extends TestCase
{
use RefreshComposerSetup;
/**
* @test
*/
public function can_global_update()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/global-update', [
'authenticatedAs' => 1,
])
);
$this->assertEquals(200, $response->getStatusCode());
}
}