mirror of
https://github.com/friendica/friendica
synced 2025-04-26 00:30:12 +00:00
Make API testable & move PhotoAlbum tests to new destination
This commit is contained in:
parent
a0c5c91886
commit
e477cf215d
10 changed files with 174 additions and 96 deletions
58
tests/src/Module/Api/ApiTest.php
Normal file
58
tests/src/Module/Api/ApiTest.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Security\Authentication;
|
||||
use Friendica\Test\FixtureTest;
|
||||
use Friendica\Test\Util\AuthenticationDouble;
|
||||
|
||||
class ApiTest extends FixtureTest
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
$this->dice = $this->dice
|
||||
->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true]);
|
||||
DI::init($this->dice);
|
||||
|
||||
$this->installAuthTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* installs auththest.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function installAuthTest()
|
||||
{
|
||||
$addon = 'authtest';
|
||||
$addon_file_path = __DIR__ . '/../../../Util/authtest/authtest.php';
|
||||
$t = @filemtime($addon_file_path);
|
||||
|
||||
@include_once($addon_file_path);
|
||||
if (function_exists($addon . '_install')) {
|
||||
$func = $addon . '_install';
|
||||
$func(DI::app());
|
||||
}
|
||||
|
||||
/** @var Database $dba */
|
||||
$dba = $this->dice->create(Database::class);
|
||||
|
||||
$dba->insert('addon', [
|
||||
'name' => $addon,
|
||||
'installed' => true,
|
||||
'timestamp' => $t,
|
||||
'plugin_admin' => function_exists($addon . '_addon_admin'),
|
||||
'hidden' => file_exists('addon/' . $addon . '/.hidden')
|
||||
]);
|
||||
|
||||
Addon::loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
}
|
27
tests/src/Module/Api/Friendica/Photo/DeleteTest.php
Normal file
27
tests/src/Module/Api/Friendica/Photo/DeleteTest.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Friendica\Photo;
|
||||
|
||||
use Friendica\Module\Api\Friendica\Photoalbum\Delete;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class DeleteTest extends ApiTest
|
||||
{
|
||||
public function testEmpty()
|
||||
{
|
||||
self::expectException(BadRequestException::class);
|
||||
Delete::rawContent();
|
||||
}
|
||||
|
||||
public function testWrong()
|
||||
{
|
||||
self::expectException(BadRequestException::class);
|
||||
Delete::rawContent(['album' => 'album_name']);
|
||||
}
|
||||
|
||||
public function testValid()
|
||||
{
|
||||
self::markTestIncomplete('We need to add a dataset for this.');
|
||||
}
|
||||
}
|
38
tests/src/Module/Api/Friendica/Photo/UpdateTest.php
Normal file
38
tests/src/Module/Api/Friendica/Photo/UpdateTest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Friendica\Photo;
|
||||
|
||||
use Friendica\Module\Api\Friendica\Photoalbum\Update;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UpdateTest extends ApiTest
|
||||
{
|
||||
public function testEmpty()
|
||||
{
|
||||
self::expectException(BadRequestException::class);
|
||||
Update::rawContent();
|
||||
}
|
||||
|
||||
public function testTooFewArgs()
|
||||
{
|
||||
self::expectException(BadRequestException::class);
|
||||
Update::rawContent(['album' => 'album_name']);
|
||||
}
|
||||
|
||||
public function testWrongUpdate()
|
||||
{
|
||||
self::expectException(BadRequestException::class);
|
||||
Update::rawContent(['album' => 'album_name', 'album_new' => 'album_name']);
|
||||
}
|
||||
|
||||
public function testUpdateWithoutAuthenticatedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
}
|
||||
|
||||
public function testValid()
|
||||
{
|
||||
self::markTestIncomplete('We need to add a dataset for this.');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue