migrate overall unittest structure

This commit is contained in:
binsky 2023-06-20 03:54:55 +02:00
Родитель 2864001581
Коммит b07bfc6811
31 изменённых файлов: 202 добавлений и 134 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -1,6 +1,7 @@
node_modules
.idea
.sass-cache
.phpunit.result.cache
npm-debug.log
# Don't mess with other dev's config

Просмотреть файл

@ -1,22 +1,16 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
<exclude>./tests/unit/lib/Db</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib/Utility</directory>
<directory suffix=".php">./lib/BackgroundJob</directory>
<directory suffix=".php">./controller</directory>
<!--<file>/path/to/file</file>-->
<!--<exclude>-->
<!--<directory suffix=".php">/path/to/dir</directory>-->
<!--<file>/path/to/file</file>-->
<!--</exclude>-->
</whitelist>
</filter>
</phpunit>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./lib/Utility</directory>
<directory suffix=".php">./lib/BackgroundJob</directory>
<directory suffix=".php">./controller</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>./tests</directory>
<exclude>./tests/unit/lib/Db</exclude>
</testsuite>
</testsuites>
</phpunit>

Просмотреть файл

@ -12,7 +12,6 @@
require_once __DIR__ . '/../../../tests/bootstrap.php';
require_once __DIR__ . '/../appinfo/autoload.php';
require_once __DIR__ . '/db/DatabaseHelperTest.php';
@ -25,4 +24,4 @@ require_once __DIR__ . '/db/DatabaseHelperTest.php';
// Fix for "Autoload path not allowed: .../files_sharing/lib/activity.php"
\OC_App::loadApp('files_sharing');
OC_Hook::clear();
OC_Hook::clear();

Просмотреть файл

@ -21,9 +21,12 @@
*
*/
use \OCA\Passman\AppInfo\Application;
namespace OCA\Passman\Tests\DB;
abstract class DatabaseHelperTest extends PHPUnit_Extensions_Database_TestCase {
use \OCA\Passman\AppInfo\Application;
use Test\TestCase;
abstract class DatabaseHelperTest extends TestCase {
CONST DUMPS_DIR = __DIR__ . '/dumps/';
/**
@ -59,7 +62,8 @@ abstract class DatabaseHelperTest extends PHPUnit_Extensions_Database_TestCase {
parent::__construct();
}
public function setUp() {
public function setUp(): void
{
if (self::$server === NULL) self::$server = new \OC\Server(getenv('SERVER_BASE_DIR'), new \OC\Config(getenv('SERVER_CONFIG_DIR'), getenv('SERVER_CONFIG_FILE')));
$this->db = self::$server->getDatabaseConnection();
@ -128,9 +132,9 @@ abstract class DatabaseHelperTest extends PHPUnit_Extensions_Database_TestCase {
/**
* Finds a subset of rows from the dataset which field name matches
* the specified value
* @param $table_name The name of the table to search into
* @param $field_name The field name
* @param $value_match The value to match data against
* @param $table_name string The name of the table to search into
* @param $field_name mixed The field name
* @param $value_match mixed The value to match data against
* @return array An array of rows
*/
public function findInDataset($table_name, $field_name, $value_match) {
@ -150,9 +154,9 @@ abstract class DatabaseHelperTest extends PHPUnit_Extensions_Database_TestCase {
/**
* Filters the given array
* @param $dataset The data to filter
* @param $field_name The array key to match against
* @param $value_match The value to compare to
* @param $dataset array The data to filter
* @param $field_name mixed The array key to match against
* @param $value_match mixed The value to compare to
*/
public function filterDataset($dataset, $field_name, $value_match) {
$ret = [];

Просмотреть файл

@ -34,7 +34,8 @@ class AppTest extends TestCase {
private $container;
public function setUp() {
public function setUp(): void
{
parent::setUp();
$app = new App('passman');
$this->container = $app->getContainer();
@ -45,4 +46,4 @@ class AppTest extends TestCase {
$this->assertTrue($appManager->isInstalled('passman'));
}
}
}

Просмотреть файл

@ -21,11 +21,16 @@
*
*/
namespace OCA\Passman\Controller;
namespace OCA\Passman\Tests\Unit\Controller;
use OCA\Passman\Controller\FileController;
use OCA\Passman\Db\FileMapper;
use OCA\Passman\Service\FileService;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use PHPUnit_Framework_TestCase;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
use Test\TestCase;
/**
* Class FileControllerTest
@ -33,7 +38,8 @@ use PHPUnit_Framework_TestCase;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\FileController
*/
class FileControllerTest extends PHPUnit_Framework_TestCase {
class FileControllerTest extends TestCase
{
private $controller;
private $userId = 'example';
@ -45,14 +51,21 @@ class FileControllerTest extends PHPUnit_Framework_TestCase {
private $shareService;
private $notificationService;
private $fileService;
private $fileMapper;
private $logger;
private $settings;
public function setUp() {
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->fileService = $this->createMock(FileService::class);
$this->controller = new FileController(
'passman', $request, $this->userId, $this->fileService
);
public function setUp(): void
{
$request = $this->getMockBuilder(IRequest::class)->getMock();
$this->fileService = $this->getMockBuilder(FileService::class)
->disableOriginalConstructor()
->getMock();
$this->fileMapper = $this->getMockBuilder(FileMapper::class)
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$this->controller = new FileController('passman', $request, $this->userId, $this->fileService, $this->logger);
}
/**
@ -66,24 +79,51 @@ class FileControllerTest extends PHPUnit_Framework_TestCase {
/**
* @covers ::getFile
*/
public function testGetFile() {
$result = $this->controller->getFile(null);
$this->assertTrue($result instanceof JSONResponse);
}
public function testGetExistingFile() {
$uploadResult = $this->controller->uploadFile('000', '0.png', 'image/png', 3);
$this->assertTrue($uploadResult instanceof JSONResponse);
/**
* @covers ::deleteFile
*/
public function testDeleteFile() {
$result = $this->controller->deleteFile(null);
$this->assertTrue($result instanceof JSONResponse);
}
var_dump($uploadResult->getData());
var_dump($this->fileMapper->getFileGuidsFromUser($this->userId));
/**
* @covers ::updateFile
*/
public function testUpdateFile() {
$result = $this->controller->getFile(0);
$this->assertTrue($result instanceof JSONResponse);
$this->assertNull($result->getData());
}
/**
* @covers ::getFile
*/
public function testGetUnspecifiedFile() {
try {
$this->controller->getFile(null);
$this->fail('Getting an unspecified file should ever fail');
} catch (\TypeError $exception) {
$this->assertStringContainsString('type int', $exception->getMessage());
}
}
/**
* @covers ::getFile
*/
public function testGetUnknownFile() {
$result = $this->controller->getFile(100000);
$this->assertNull($result->getData());
}
/**
* @covers ::deleteFile
*/
/*public function testDeleteFile() {
$result = $this->controller->deleteFile(null);
$this->assertTrue($result instanceof JSONResponse);
}*/
/**
* @covers ::updateFile
*/
/*public function testUpdateFile() {
$this->controller->updateFile('6AD30804-BFFC-4EFC-97F8-20A126FA1709', '0' , '0.jpg');
$this->assertTrue(true);
}
}*/
}

Просмотреть файл

@ -24,7 +24,7 @@
namespace OCA\Passman\Controller;
use OCP\AppFramework\Http\JSONResponse;
use PHPUnit_Framework_TestCase;
use Test\TestCase;
/**
* Class InternalControllerTest
@ -32,13 +32,14 @@ use PHPUnit_Framework_TestCase;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\InternalController
*/
class InternalControllerTest extends PHPUnit_Framework_TestCase {
class InternalControllerTest extends TestCase {
private $controller;
private $userId = 'john';
private $credentialService;
public function setUp() {
public function setUp(): void
{
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$config = $this->getMockBuilder('OCP\IConfig')->getMock();
$this->credentialService = $this->getMockBuilder('OCA\Passman\Service\CredentialService')

Просмотреть файл

@ -24,7 +24,7 @@
namespace OCA\Passman\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use PHPUnit_Framework_TestCase;
use Test\TestCase;
/**
* Class PageControllerTest
@ -32,12 +32,13 @@ use PHPUnit_Framework_TestCase;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\PageController
*/
class PageControllerTest extends PHPUnit_Framework_TestCase {
class PageControllerTest extends TestCase {
private $controller;
private $userId = 'john';
public function setUp() {
public function setUp(): void
{
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->controller = new PageController(

Просмотреть файл

@ -26,7 +26,7 @@ namespace OCA\Passman\Controller;
use OCA\Passman\Service\SettingsService;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use PHPUnit_Framework_TestCase;
use Test\TestCase;
/**
* Class SettingsControllerTest
@ -34,11 +34,12 @@ use PHPUnit_Framework_TestCase;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\SettingsController
*/
class SettingsControllerTest extends PHPUnit_Framework_TestCase {
class SettingsControllerTest extends TestCase {
private $controller;
public function setUp() {
public function setUp(): void
{
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$IL10N = $this->getMockBuilder('OCP\IL10N')->getMock();
$config = $this->getMockBuilder('OCP\IConfig')->getMock();

Просмотреть файл

@ -24,7 +24,7 @@
namespace OCA\Passman\Controller;
use OCP\AppFramework\Http\JSONResponse;
use PHPUnit_Framework_TestCase;
use Test\TestCase;
/**
@ -33,11 +33,12 @@ use PHPUnit_Framework_TestCase;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\TranslationController
*/
class TranslationControllerTest extends PHPUnit_Framework_TestCase {
class TranslationControllerTest extends TestCase {
private $controller;
public function setUp() {
public function setUp(): void
{
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$IL10N = $this->getMockBuilder('OCP\IL10N')->getMock();

Просмотреть файл

@ -28,7 +28,7 @@ use OCA\Passman\Service\DeleteVaultRequestService;
use OCA\Passman\Service\SettingsService;
use OCA\Passman\Service\VaultService;
use OCP\AppFramework\Http\JSONResponse;
use PHPUnit_Framework_TestCase;
use Test\TestCase;
/**
* Class VaultControllerTest
@ -36,7 +36,7 @@ use PHPUnit_Framework_TestCase;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\VaultController
*/
class VaultControllerTest extends PHPUnit_Framework_TestCase {
class VaultControllerTest extends TestCase {
private $controller;
private $userId = 'example';
@ -44,7 +44,8 @@ class VaultControllerTest extends PHPUnit_Framework_TestCase {
private $vaultService;
private $deleteVaultRequestService;
public function setUp() {
public function setUp(): void
{
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->vaultService = $this->createMock(VaultService::class);
$this->credentialService = $this->createMock(CredentialService::class);

Просмотреть файл

@ -23,9 +23,9 @@
namespace OCA\Passman\Tests\BackgroundJob;
use PHPUnit_Framework_TestCase;
use OCA\Passman\BackgroundJob\ExpireCredentials;
use OCP\IConfig;
use Test\TestCase;
/**
* Class ExpireCredentialsTest
@ -34,7 +34,7 @@ use OCP\IConfig;
* @package OCA\Passman\Tests\BackgroundJob
* @covers \OCA\Passman\BackgroundJob\ExpireCredentials
*/
class ExpireCredentialsTest extends PHPUnit_Framework_TestCase {
class ExpireCredentialsTest extends TestCase {
public function testRun() {
$backgroundJob = new ExpireCredentials(
$this->getMockBuilder(IConfig::class)->getMock()

Просмотреть файл

@ -24,11 +24,12 @@
use \OCA\Passman\Db\CredentialMapper;
use \OCA\Passman\Db\Credential;
use \OCA\Passman\Utility\Utils;
use Test\TestCase;
/**
* @coversDefaultClass \OCA\Passman\Db\CredentialMapper
*/
class CredentialMapperTest extends DatabaseHelperTest {
class CredentialMapperTest extends TestCase {
CONST TABLES = [
'oc_passman_credentials'
];
@ -46,7 +47,8 @@ class CredentialMapperTest extends DatabaseHelperTest {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
parent::setUp();
$this->mapper = new CredentialMapper($this->db, new Utils());
$this->dataset = $this->getTableDataset(self::TABLES[0]);
@ -286,4 +288,4 @@ class CredentialMapperTest extends DatabaseHelperTest {
$this->mapper->getCredentialById($cred->getId())->jsonSerialize()
);
}
}
}

Просмотреть файл

@ -24,11 +24,12 @@
use \OCA\Passman\Db\CredentialRevisionMapper;
use \OCA\Passman\Db\CredentialRevision;
use \OCA\Passman\Utility\Utils;
use Test\TestCase;
/**
* @coversDefaultClass \OCA\Passman\Db\CredentialRevisionMapper
*/
class CredentialRevisionMapperTest extends DatabaseHelperTest {
class CredentialRevisionMapperTest extends TestCase {
CONST TABLES = [
'oc_passman_revisions'
];
@ -46,7 +47,8 @@ class CredentialRevisionMapperTest extends DatabaseHelperTest {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
parent::setUp();
$this->mapper = new CredentialRevisionMapper($this->db, new Utils());
$this->dataset = $this->getTableDataset(self::TABLES[0]);
@ -130,4 +132,4 @@ class CredentialRevisionMapperTest extends DatabaseHelperTest {
$this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
$this->mapper->getRevision($row->getId(), $row->getUserId());
}
}
}

Просмотреть файл

@ -26,7 +26,7 @@ use \OCA\Passman\Db\CredentialRevision;
/**
* @coversDefaultClass \OCA\Passman\Db\CredentialRevision
*/
class CredentialRevisionTest extends PHPUnit_Framework_TestCase {
class CredentialRevisionTest extends \Test\TestCase {
CONST TEST_DATA = [
'id' => 30,
'guid' => 'FA8D80E0-90AB-4D7A-9937-913F486C24EA',
@ -45,7 +45,8 @@ class CredentialRevisionTest extends PHPUnit_Framework_TestCase {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->revision = CredentialRevision::fromRow(self::TEST_DATA);
}
@ -90,4 +91,4 @@ class CredentialRevisionTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_array, $actual_array);
}
}
}

Просмотреть файл

@ -30,7 +30,7 @@ use \OCP\AppFramework\Db\Entity;
* @uses \OCP\AppFramework\Db\Entity
* @uses \JsonSerializable
*/
class CredentialTest extends PHPUnit_Framework_TestCase {
class CredentialTest extends \Test\TestCase {
CONST TEST_DATA = [
'id' => 5,
'guid' => 'FA8D80E0-90AB-4D7A-9937-913F486C24EA',
@ -64,7 +64,8 @@ class CredentialTest extends PHPUnit_Framework_TestCase {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->credential = Credential::fromRow(self::TEST_DATA);
}
@ -151,4 +152,4 @@ class CredentialTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($comparision_array, $json_array);
}
}
}

Просмотреть файл

@ -26,7 +26,7 @@ use \OCA\Passman\Db\EntityJSONSerializer;
/**
* @coversDefaultClass \OCA\Passman\Db\EntityJSONSerializer
*/
class EntityJSONSerializerTest extends PHPUnit_Framework_TestCase {
class EntityJSONSerializerTest extends \Test\TestCase {
CONST TEST_FIELDS = [
'an_string' => 'value',
'an_int' => 1234,
@ -42,7 +42,8 @@ class EntityJSONSerializerTest extends PHPUnit_Framework_TestCase {
*/
protected $trait;
public function setUp() {
public function setUp(): void
{
$this->trait = $this->getObjectForTrait(EntityJSONSerializer::class);
foreach (self::TEST_FIELDS as $key => $value){
@ -70,4 +71,4 @@ class EntityJSONSerializerTest extends PHPUnit_Framework_TestCase {
}
$this->assertEquals($expected_data, $actual_data);
}
}
}

Просмотреть файл

@ -23,6 +23,8 @@
use \OCA\Passman\Db\FileMapper;
use \OCA\Passman\Db\File;
use OCA\Passman\Tests\DB\DatabaseHelperTest;
use Test\TestCase;
/**
* @coversDefaultClass \OCA\Passman\Db\FileMapper
@ -45,7 +47,8 @@ class FileMapperTest extends DatabaseHelperTest {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
parent::setUp();
$this->mapper = new FileMapper($this->db, new \OCA\Passman\Utility\Utils());
$this->dataset = $this->getTableDataset(self::TABLES[0]);
@ -143,4 +146,4 @@ class FileMapperTest extends DatabaseHelperTest {
$final = $this->mapper->getFileByGuid($expected->getGuid());
$this->assertEquals($expected->jsonSerialize(), $final->jsonSerialize());
}
}
}

Просмотреть файл

@ -26,7 +26,7 @@ use \OCA\Passman\Db\File;
/**
* @coversDefaultClass \OCA\Passman\Db\File
*/
class FileTest extends PHPUnit_Framework_TestCase {
class FileTest extends \Test\TestCase {
CONST TEST_DATA = [
'id' => 21,
'guid' => 'FC148F1A-AA67-489E-ABF5-4D7AA525F067',
@ -46,7 +46,8 @@ class FileTest extends PHPUnit_Framework_TestCase {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->file = File::fromRow(self::TEST_DATA);
}
@ -96,4 +97,4 @@ class FileTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_result, $actual_data);
}
}
}

Просмотреть файл

@ -23,12 +23,13 @@
use OCA\Passman\Db\ShareRequestMapper;
use OCA\Passman\Db\ShareRequest;
use Test\TestCase;
/**
* @coversDefaultClass OCA\Passman\Db\ShareRequestMapper
*/
class ShareRequestMapperTest extends DatabaseHelperTest {
class ShareRequestMapperTest extends TestCase {
CONST TABLES = [
'oc_passman_share_request'
];
@ -46,7 +47,8 @@ class ShareRequestMapperTest extends DatabaseHelperTest {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
parent::setUp();
$this->dataset = $this->getTableDataset(self::TABLES[0]);
$this->mapper = new ShareRequestMapper($this->db);
@ -303,4 +305,4 @@ class ShareRequestMapperTest extends DatabaseHelperTest {
}
}
}
}
}

Просмотреть файл

@ -27,7 +27,7 @@ use \OCA\Passman\Utility\PermissionEntity;
/**
* @coversDefaultClass \OCA\Passman\Db\ShareRequest
*/
class ShareRequestTest extends PHPUnit_Framework_TestCase {
class ShareRequestTest extends \Test\TestCase {
CONST TEST_DATA = [
'id' => 233,
'item_id' => 5,
@ -49,7 +49,8 @@ class ShareRequestTest extends PHPUnit_Framework_TestCase {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->request = ShareRequest::fromRow(self::TEST_DATA);
}
@ -142,4 +143,4 @@ class ShareRequestTest extends PHPUnit_Framework_TestCase {
$this->assertSame($expected_result, $actual_data);
}
}
}

Просмотреть файл

@ -23,11 +23,12 @@
use \OCA\Passman\Db\SharingACLMapper;
use \OCA\Passman\Db\SharingACL;
use Test\TestCase;
/**
* @coversDefaultClass \OCA\Passman\Db\SharingACLMapper
*/
class SharingACLMapperTest extends DatabaseHelperTest {
class SharingACLMapperTest extends TestCase {
CONST TABLES = [
'oc_passman_sharing_acl'
];
@ -52,7 +53,8 @@ class SharingACLMapperTest extends DatabaseHelperTest {
return self::TABLES;
}
public function setUp() {
public function setUp(): void
{
parent::setUp();
$this->mapper = new SharingACLMapper($this->db);
$this->dataset = $this->getTableDataset(self::TABLES[0]);
@ -160,4 +162,4 @@ class SharingACLMapperTest extends DatabaseHelperTest {
$test_data->getItemGuid()
);
}
}
}

Просмотреть файл

@ -27,7 +27,7 @@ use \OCA\Passman\Utility\PermissionEntity;
/**
* @coversDefaultClass \OCA\Passman\Db\SharingACL
*/
class SharingACLTest extends PHPUnit_Framework_TestCase {
class SharingACLTest extends \Test\TestCase {
CONST TEST_DATA = [
'id' => 55,
'item_id' => 5,
@ -50,7 +50,8 @@ class SharingACLTest extends PHPUnit_Framework_TestCase {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->acl = SharingACL::fromRow(self::TEST_DATA);
}
@ -128,4 +129,4 @@ class SharingACLTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_data, $actual_data);
}
}
}

Просмотреть файл

@ -24,12 +24,13 @@
use \OCA\Passman\Db\VaultMapper;
use \OCA\Passman\Utility\Utils;
use \OCA\Passman\Db\Vault;
use Test\TestCase;
/**
* Unit tests for VaultMapper
* @coversDefaultClass \OCA\Passman\Db\VaultMapper
*/
class VaultMapperTest extends DatabaseHelperTest {
class VaultMapperTest extends TestCase {
CONST TABLES = [
'oc_passman_vaults'
];
@ -44,7 +45,8 @@ class VaultMapperTest extends DatabaseHelperTest {
*/
protected $vaults_dataset;
public function setUp() {
public function setUp(): void
{
parent::setUp();
$this->vault_mapper = new VaultMapper($this->db, new Utils());
$this->vaults_dataset = $this->getTableDataset(self::TABLES[0]);

Просмотреть файл

@ -26,7 +26,7 @@ use \OCA\Passman\Db\Vault;
/**
* @coversDefaultClass \OCA\Passman\Db\Vault
*/
class VaultTest extends PHPUnit_Framework_TestCase {
class VaultTest extends \Test\TestCase {
CONST TEST_DATA = [
'id' => 1,
'guid' => 'FA8D80E0-90AB-4D7A-9937-913F486C24EA',
@ -54,7 +54,8 @@ pbbPwdc88kGcdqBzWQIDAQAB
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->vault = Vault::fromRow(self::TEST_DATA);
}
@ -115,4 +116,4 @@ pbbPwdc88kGcdqBzWQIDAQAB
$this->assertEquals($expected_data, $actual_data);
}
}
}

Просмотреть файл

@ -27,8 +27,8 @@ use OCA\Passman\Service\EncryptService;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use PHPUnit_Framework_TestCase;
use OCA\Passman\Service\SettingsService;
use Test\TestCase;
/**
* Class SettingsServiceTest
@ -36,12 +36,13 @@ use OCA\Passman\Service\SettingsService;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Service\EncryptService
*/
class EncryptServiceTest extends PHPUnit_Framework_TestCase {
class EncryptServiceTest extends TestCase {
private $service;
private $testKey;
public function setUp() {
public function setUp(): void
{
$config = $this->getMockBuilder('OCP\IConfig')->getMock();
$userId = 'admin';
$settings_service = new SettingsService($userId, $config, 'passman');
@ -56,4 +57,4 @@ class EncryptServiceTest extends PHPUnit_Framework_TestCase {
$this->testKey = $this->service->makeKey('userKey', 'serverKey', 'userSuppliedKey');
$this->assertTrue($this->testKey === '967efb38599fb81ebc95b280e7c86cda0593e469f6a391caf9e9fee7c3976fd1edcdeefdb6a99e9f0bc47fda4b77fb8309c1955211dccf1dab1aad00c2ad5656');
}
}
}

Просмотреть файл

@ -24,8 +24,8 @@
namespace OCA\Passman\Controller;
use OCA\Passman\Service\IconService;
use PHPUnit_Framework_TestCase;
use OCA\Passman\Service\SettingsService;
use Test\TestCase;
/**
* Class SettingsServiceTest
@ -33,12 +33,13 @@ use OCA\Passman\Service\SettingsService;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Service\EncryptService
*/
class IconServiceTest extends PHPUnit_Framework_TestCase {
class IconServiceTest extends TestCase {
private $service;
private $testKey;
public function setUp() {
public function setUp(): void
{
$this->options = array(
'sslVerify' => false,
);
@ -122,4 +123,4 @@ class IconServiceTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('head absolute', $fav->findMethod);
}
}
}

Просмотреть файл

@ -26,8 +26,8 @@ namespace OCA\Passman\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use PHPUnit_Framework_TestCase;
use OCA\Passman\Service\SettingsService;
use Test\TestCase;
/**
* Class SettingsServiceTest
@ -35,11 +35,12 @@ use OCA\Passman\Service\SettingsService;
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Service\SettingsService
*/
class SettingsServiceTest extends PHPUnit_Framework_TestCase {
class SettingsServiceTest extends TestCase {
private $service;
public function setUp() {
public function setUp(): void
{
$config = $this->getMockBuilder('OCP\IConfig')->getMock();
$userId = 'admin';
$this->service = new SettingsService($userId, $config, 'passman');
@ -83,4 +84,4 @@ class SettingsServiceTest extends PHPUnit_Framework_TestCase {
$result = $this->service->isEnabled('link_sharing_enabled');
$this->assertFalse($result);
}
}
}

Просмотреть файл

@ -27,7 +27,7 @@ use \OCP\AppFramework\Http;
/**
* @coversDefaultClass \OCA\Passman\Utility\NotFoundJSONResponse
*/
class NotFoundJSONResponseTest extends PHPUnit_Framework_TestCase {
class NotFoundJSONResponseTest extends \Test\TestCase {
/**
* @covers ::__construct
*/
@ -50,4 +50,4 @@ class NotFoundJSONResponseTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
$this->assertJsonStringEqualsJsonString(json_encode($data), $response->render(), 'Rendered data does not match with expected data');
}
}
}

Просмотреть файл

@ -26,7 +26,7 @@ use \OCA\Passman\Utility\PermissionEntity;
/**
* @coversDefaultClass \OCA\Passman\Utility\PermissionEntity
*/
class PermissionsEntityTest extends PHPUnit_Framework_TestCase {
class PermissionsEntityTest extends \Test\TestCase {
/**
* @var PermissionEntity
*/
@ -35,9 +35,10 @@ class PermissionsEntityTest extends PHPUnit_Framework_TestCase {
/**
* @after
*/
public function setUp() {
public function setUp(): void
{
$this->permission = new PermissionEntity();
$this->permission->permissions = 0;
$this->permission->setPermissions(0);
}
/**
@ -105,4 +106,4 @@ class PermissionsEntityTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($this->permission->hasPermission(PermissionEntity::READ));
$this->assertTrue($this->permission->hasPermission(PermissionEntity::HISTORY));
}
}
}

Просмотреть файл

@ -26,7 +26,7 @@ use OCA\Passman\Utility\Utils;
/**
* @coversDefaultClass OCA\Passman\Utility\Utils
*/
class UtilsTest extends PHPUnit_Framework_TestCase {
class UtilsTest extends \Test\TestCase {
/**
* @covers ::GUID
*/
@ -65,4 +65,4 @@ class UtilsTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($old_time < $new_time, "Evaluating that $old_time < $new_time");
}
}
}