mirror of
https://github.com/flarum/framework.git
synced 2025-06-01 21:13:24 +08:00
126 lines
3.4 KiB
PHP
126 lines
3.4 KiB
PHP
<?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\extensions;
|
|
|
|
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
|
|
use Flarum\PackageManager\Tests\integration\TestCase;
|
|
|
|
class RequireExtensionTest extends TestCase
|
|
{
|
|
use RefreshComposerSetup;
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function extension_uninstalled_by_default()
|
|
{
|
|
$this->assertExtensionNotExists('v17development-blog');
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function requiring_an_existing_extension_fails()
|
|
{
|
|
$response = $this->send(
|
|
$this->request('POST', '/api/package-manager/extensions', [
|
|
'authenticatedAs' => 1,
|
|
'json' => [
|
|
'data' => [
|
|
'package' => 'flarum/tags'
|
|
]
|
|
]
|
|
])
|
|
);
|
|
|
|
$this->assertEquals(409, $response->getStatusCode());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function requiring_a_compatible_extension_works()
|
|
{
|
|
$response = $this->send(
|
|
$this->request('POST', '/api/package-manager/extensions', [
|
|
'authenticatedAs' => 1,
|
|
'json' => [
|
|
'data' => [
|
|
'package' => 'v17development/flarum-blog'
|
|
]
|
|
]
|
|
])
|
|
);
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
$this->assertExtensionExists('v17development-blog');
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function requiring_a_compatible_extension_with_specific_version_works()
|
|
{
|
|
$response = $this->send(
|
|
$this->request('POST', '/api/package-manager/extensions', [
|
|
'authenticatedAs' => 1,
|
|
'json' => [
|
|
'data' => [
|
|
'package' => 'v17development/flarum-blog:0.4.0'
|
|
]
|
|
]
|
|
])
|
|
);
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
$this->assertExtensionExists('v17development-blog');
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function requiring_an_uncompatible_extension_fails()
|
|
{
|
|
$response = $this->send(
|
|
$this->request('POST', '/api/package-manager/extensions', [
|
|
'authenticatedAs' => 1,
|
|
'json' => [
|
|
'data' => [
|
|
'package' => 'flarum/auth-github'
|
|
]
|
|
]
|
|
])
|
|
);
|
|
|
|
$this->assertEquals(409, $response->getStatusCode());
|
|
$this->assertEquals('extension_incompatible_with_instance', $this->errorDetails($response)['guessed_cause']);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function requiring_an_uncompatible_extension_with_specific_version_fails()
|
|
{
|
|
$response = $this->send(
|
|
$this->request('POST', '/api/package-manager/extensions', [
|
|
'authenticatedAs' => 1,
|
|
'json' => [
|
|
'data' => [
|
|
'package' => 'flarum/auth-github:0.1.0-beta.9'
|
|
]
|
|
]
|
|
])
|
|
);
|
|
|
|
$this->assertEquals(409, $response->getStatusCode());
|
|
$this->assertEquals('extension_incompatible_with_instance', $this->errorDetails($response)['guessed_cause']);
|
|
}
|
|
}
|