mirror of
https://github.com/flarum/core.git
synced 2025-08-13 11:54:32 +02:00
Extension Tests (#9)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?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 RemoveExtensionTest extends TestCase
|
||||
{
|
||||
use RefreshComposerSetup;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extension_installed_by_default()
|
||||
{
|
||||
$this->assertExtensionExists('flarum-tags');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function removing_an_extension_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('DELETE', '/api/package-manager/extensions/flarum-tags', [
|
||||
'authenticatedAs' => 1
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(204, $response->getStatusCode());
|
||||
$this->assertExtensionNotExists('flarum-tags');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function removing_a_non_existant_extension_fails()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('DELETE', '/api/package-manager/extensions/flarum-potato', [
|
||||
'authenticatedAs' => 1
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(409, $response->getStatusCode());
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
<?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_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->guessedCause($response));
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
<?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 UpdateExtensionTest extends TestCase
|
||||
{
|
||||
use RefreshComposerSetup;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extension_installed_by_default()
|
||||
{
|
||||
$this->assertExtensionExists('flarum-tags');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function updating_an_existing_extension_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('PATCH', '/api/package-manager/extensions/flarum-tags', [
|
||||
'authenticatedAs' => 1,
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(204, $response->getStatusCode());
|
||||
$this->assertExtensionExists('flarum-tags');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function updating_a_non_existing_extension_fails()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('PATCH', '/api/package-manager/extensions/flarum-potato', [
|
||||
'authenticatedAs' => 1,
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(409, $response->getStatusCode());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user