@@ -21,34 +21,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use Test\TestCase;
|
||||
|
||||
|
||||
/**
|
||||
* This test shows how to make a small Integration Test. Query your class
|
||||
* directly from the container, only pass in mocks if needed and run your tests
|
||||
* against the database
|
||||
*/
|
||||
class AppTest extends TestCase {
|
||||
|
||||
private $container;
|
||||
private $container;
|
||||
private $app;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->app = new \OCA\Deck\AppInfo\Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
}
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->app = new \OCA\Deck\AppInfo\Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
}
|
||||
|
||||
public function testAppInstalled() {
|
||||
$appManager = $this->container->query('OCP\App\IAppManager');
|
||||
$this->assertTrue($appManager->isInstalled('deck'));
|
||||
}
|
||||
public function testAppInstalled() {
|
||||
$appManager = $this->container->query('OCP\App\IAppManager');
|
||||
$this->assertTrue($appManager->isInstalled('deck'));
|
||||
}
|
||||
|
||||
public function testNavigationEntry() {
|
||||
public function testNavigationEntry() {
|
||||
$this->app->registerNavigationEntry();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ use OCA\Deck\Service\CardService;
|
||||
* @coversDefaultClass OCA\Deck\Db\AssignedUsersMapper
|
||||
*/
|
||||
class AssignedUsersMapperTest extends \Test\TestCase {
|
||||
|
||||
private const TEST_USER1 = 'test-share-user1';
|
||||
private const TEST_USER3 = 'test-share-user3';
|
||||
private const TEST_USER2 = 'test-share-user2';
|
||||
|
||||
@@ -24,63 +24,62 @@
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class BoardDatabaseTest extends \Test\TestCase
|
||||
{
|
||||
const TEST_USER1 = "test-share-user1";
|
||||
const TEST_USER2 = "test-share-user2";
|
||||
const TEST_USER3 = "test-share-user3";
|
||||
const TEST_USER4 = "test-share-user4";
|
||||
const TEST_GROUP1 = "test-share-group1";
|
||||
class BoardDatabaseTest extends \Test\TestCase {
|
||||
public const TEST_USER1 = "test-share-user1";
|
||||
public const TEST_USER2 = "test-share-user2";
|
||||
public const TEST_USER3 = "test-share-user3";
|
||||
public const TEST_USER4 = "test-share-user4";
|
||||
public const TEST_GROUP1 = "test-share-group1";
|
||||
|
||||
/** @var \OCA\Deck\Service\BoardService */
|
||||
private $boardService;
|
||||
/** @var \OCA\Deck\Service\BoardService */
|
||||
private $boardService;
|
||||
|
||||
public static function setUpBeforeClass(): void {
|
||||
parent::setUpBeforeClass();
|
||||
public static function setUpBeforeClass(): void {
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
$backend = new \Test\Util\User\Dummy();
|
||||
\OC_User::useBackend($backend);
|
||||
$backend->createUser(self::TEST_USER1, self::TEST_USER1);
|
||||
$backend->createUser(self::TEST_USER2, self::TEST_USER2);
|
||||
$backend->createUser(self::TEST_USER3, self::TEST_USER3);
|
||||
$backend->createUser(self::TEST_USER4, self::TEST_USER4);
|
||||
// create group
|
||||
$groupBackend = new \Test\Util\Group\Dummy();
|
||||
$groupBackend->createGroup(self::TEST_GROUP1);
|
||||
$groupBackend->createGroup('group');
|
||||
$groupBackend->createGroup('group1');
|
||||
$groupBackend->createGroup('group2');
|
||||
$groupBackend->createGroup('group3');
|
||||
$groupBackend->addToGroup(self::TEST_USER1, 'group');
|
||||
$groupBackend->addToGroup(self::TEST_USER2, 'group');
|
||||
$groupBackend->addToGroup(self::TEST_USER3, 'group');
|
||||
$groupBackend->addToGroup(self::TEST_USER2, 'group1');
|
||||
$groupBackend->addToGroup(self::TEST_USER3, 'group2');
|
||||
$groupBackend->addToGroup(self::TEST_USER4, 'group3');
|
||||
$groupBackend->addToGroup(self::TEST_USER2, self::TEST_GROUP1);
|
||||
\OC::$server->getGroupManager()->addBackend($groupBackend);
|
||||
}
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
\OC::$server->getUserSession()->login(self::TEST_USER1, self::TEST_USER1);
|
||||
$this->boardService = \OC::$server->query("\OCA\Deck\Service\BoardService");
|
||||
}
|
||||
public function testCreate() {
|
||||
$board = new \OCA\Deck\Db\Board();
|
||||
$board->setTitle('Test');
|
||||
$board->setOwner(self::TEST_USER1);
|
||||
$board->setColor('000000');
|
||||
$board->setLabels([]);
|
||||
$created = $this->boardService->create('Test', self::TEST_USER1, '000000');
|
||||
$id = $created->getId();
|
||||
$actual = $this->boardService->find($id);
|
||||
$this->assertEquals($actual->getTitle(), $board->getTitle());
|
||||
$this->assertEquals($actual->getColor(), $board->getColor());
|
||||
$this->assertEquals($actual->getOwner(), $board->getOwner());
|
||||
$this->boardService->deleteForce($id);
|
||||
}
|
||||
$backend = new \Test\Util\User\Dummy();
|
||||
\OC_User::useBackend($backend);
|
||||
$backend->createUser(self::TEST_USER1, self::TEST_USER1);
|
||||
$backend->createUser(self::TEST_USER2, self::TEST_USER2);
|
||||
$backend->createUser(self::TEST_USER3, self::TEST_USER3);
|
||||
$backend->createUser(self::TEST_USER4, self::TEST_USER4);
|
||||
// create group
|
||||
$groupBackend = new \Test\Util\Group\Dummy();
|
||||
$groupBackend->createGroup(self::TEST_GROUP1);
|
||||
$groupBackend->createGroup('group');
|
||||
$groupBackend->createGroup('group1');
|
||||
$groupBackend->createGroup('group2');
|
||||
$groupBackend->createGroup('group3');
|
||||
$groupBackend->addToGroup(self::TEST_USER1, 'group');
|
||||
$groupBackend->addToGroup(self::TEST_USER2, 'group');
|
||||
$groupBackend->addToGroup(self::TEST_USER3, 'group');
|
||||
$groupBackend->addToGroup(self::TEST_USER2, 'group1');
|
||||
$groupBackend->addToGroup(self::TEST_USER3, 'group2');
|
||||
$groupBackend->addToGroup(self::TEST_USER4, 'group3');
|
||||
$groupBackend->addToGroup(self::TEST_USER2, self::TEST_GROUP1);
|
||||
\OC::$server->getGroupManager()->addBackend($groupBackend);
|
||||
}
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
\OC::$server->getUserSession()->login(self::TEST_USER1, self::TEST_USER1);
|
||||
$this->boardService = \OC::$server->query("\OCA\Deck\Service\BoardService");
|
||||
}
|
||||
public function testCreate() {
|
||||
$board = new \OCA\Deck\Db\Board();
|
||||
$board->setTitle('Test');
|
||||
$board->setOwner(self::TEST_USER1);
|
||||
$board->setColor('000000');
|
||||
$board->setLabels([]);
|
||||
$created = $this->boardService->create('Test', self::TEST_USER1, '000000');
|
||||
$id = $created->getId();
|
||||
$actual = $this->boardService->find($id);
|
||||
$this->assertEquals($actual->getTitle(), $board->getTitle());
|
||||
$this->assertEquals($actual->getColor(), $board->getColor());
|
||||
$this->assertEquals($actual->getOwner(), $board->getOwner());
|
||||
$this->boardService->deleteForce($id);
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
parent::tearDown();
|
||||
}
|
||||
public function tearDown(): void {
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ use GuzzleHttp\Message\ResponseInterface;
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
trait BasicStructure {
|
||||
|
||||
use Auth;
|
||||
|
||||
/** @var string */
|
||||
@@ -104,7 +103,7 @@ trait BasicStructure {
|
||||
*/
|
||||
public function usingServer($server) {
|
||||
$previousServer = $this->currentServer;
|
||||
if ($server === 'LOCAL'){
|
||||
if ($server === 'LOCAL') {
|
||||
$this->baseUrl = $this->localBaseUrl;
|
||||
$this->currentServer = 'LOCAL';
|
||||
return $previousServer;
|
||||
@@ -139,8 +138,10 @@ trait BasicStructure {
|
||||
* @param array $arrayOfArrays
|
||||
* @return array
|
||||
*/
|
||||
public function simplifyArray($arrayOfArrays){
|
||||
$a = array_map(function($subArray) { return $subArray[0]; }, $arrayOfArrays);
|
||||
public function simplifyArray($arrayOfArrays) {
|
||||
$a = array_map(function ($subArray) {
|
||||
return $subArray[0];
|
||||
}, $arrayOfArrays);
|
||||
return $a;
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@ trait BasicStructure {
|
||||
}
|
||||
}
|
||||
|
||||
public function isExpectedUrl($possibleUrl, $finalPart){
|
||||
public function isExpectedUrl($possibleUrl, $finalPart) {
|
||||
$baseUrlChopped = substr($this->baseUrl, 0, -4);
|
||||
$endCharacter = strlen($baseUrlChopped) + strlen($finalPart);
|
||||
return (substr($possibleUrl,0,$endCharacter) == "$baseUrlChopped" . "$finalPart");
|
||||
@@ -328,7 +329,7 @@ trait BasicStructure {
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeFile($path, $filename){
|
||||
public static function removeFile($path, $filename) {
|
||||
if (file_exists("$path" . "$filename")) {
|
||||
unlink("$path" . "$filename");
|
||||
}
|
||||
@@ -352,7 +353,7 @@ trait BasicStructure {
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
public function createFileWithText($name, $text){
|
||||
public function createFileWithText($name, $text) {
|
||||
$file = fopen("work/" . "$name", 'w');
|
||||
fwrite($file, $text);
|
||||
fclose($file);
|
||||
@@ -387,8 +388,8 @@ trait BasicStructure {
|
||||
/**
|
||||
* @BeforeSuite
|
||||
*/
|
||||
public static function addFilesToSkeleton(){
|
||||
for ($i=0; $i<5; $i++){
|
||||
public static function addFilesToSkeleton() {
|
||||
for ($i=0; $i<5; $i++) {
|
||||
file_put_contents("../../core/skeleton/" . "textfile" . "$i" . ".txt", "Nextcloud test text file\n");
|
||||
}
|
||||
if (!file_exists("../../core/skeleton/FOLDER")) {
|
||||
@@ -407,8 +408,8 @@ trait BasicStructure {
|
||||
/**
|
||||
* @AfterSuite
|
||||
*/
|
||||
public static function removeFilesFromSkeleton(){
|
||||
for ($i=0; $i<5; $i++){
|
||||
public static function removeFilesFromSkeleton() {
|
||||
for ($i=0; $i<5; $i++) {
|
||||
self::removeFile("../../core/skeleton/", "textfile" . "$i" . ".txt");
|
||||
}
|
||||
if (is_dir("../../core/skeleton/FOLDER")) {
|
||||
@@ -427,11 +428,11 @@ trait BasicStructure {
|
||||
/**
|
||||
* @BeforeScenario @local_storage
|
||||
*/
|
||||
public static function removeFilesFromLocalStorageBefore(){
|
||||
public static function removeFilesFromLocalStorageBefore() {
|
||||
$dir = "./work/local_storage/";
|
||||
$di = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
|
||||
$ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ( $ri as $file ) {
|
||||
foreach ($ri as $file) {
|
||||
$file->isDir() ? rmdir($file) : unlink($file);
|
||||
}
|
||||
}
|
||||
@@ -439,11 +440,11 @@ trait BasicStructure {
|
||||
/**
|
||||
* @AfterScenario @local_storage
|
||||
*/
|
||||
public static function removeFilesFromLocalStorageAfter(){
|
||||
public static function removeFilesFromLocalStorageAfter() {
|
||||
$dir = "./work/local_storage/";
|
||||
$di = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
|
||||
$ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ( $ri as $file ) {
|
||||
foreach ($ri as $file) {
|
||||
$file->isDir() ? rmdir($file) : unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use GuzzleHttp\Client;
|
||||
use Behat\Behat\Tester\Exception\PendingException;
|
||||
use Behat\Gherkin\Node\PyStringNode;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class FeatureContext implements Context {
|
||||
|
||||
use WebDav;
|
||||
|
||||
/** @var string */
|
||||
private $mappedUserId;
|
||||
|
||||
private $lastInsertIds = array();
|
||||
private $lastInsertIds = [];
|
||||
|
||||
/**
|
||||
* @BeforeSuite
|
||||
@@ -117,8 +115,8 @@ class FeatureContext implements Context {
|
||||
*/
|
||||
public function theResponseShouldBeAJsonArrayWithALengthOf($length) {
|
||||
$realResponseArray = json_decode($this->response->getBody()->getContents(), true);
|
||||
PHPUnit_Framework_Assert::assertEquals($realResponseArray, "foo");
|
||||
if((int)count($realResponseArray) !== (int)$length) {
|
||||
PHPUnit_Framework_Assert::assertEquals($realResponseArray, "foo");
|
||||
if ((int)count($realResponseArray) !== (int)$length) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Expected %d as length got %d',
|
||||
@@ -129,26 +127,25 @@ class FeatureContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^I should get:$/
|
||||
*
|
||||
* @param PyStringNode $string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function iShouldGet(PyStringNode $string)
|
||||
{
|
||||
if ((string) $string !== trim($this->cliOutput)) {
|
||||
throw new Exception(sprintf(
|
||||
'Expected "%s" but received "%s".',
|
||||
$string,
|
||||
$this->cliOutput
|
||||
));
|
||||
}
|
||||
/**
|
||||
* @Then /^I should get:$/
|
||||
*
|
||||
* @param PyStringNode $string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function iShouldGet(PyStringNode $string) {
|
||||
if ((string) $string !== trim($this->cliOutput)) {
|
||||
throw new Exception(sprintf(
|
||||
'Expected "%s" but received "%s".',
|
||||
$string,
|
||||
$this->cliOutput
|
||||
));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private function sendJSONrequest($method, $url, $data) {
|
||||
private function sendJSONrequest($method, $url, $data) {
|
||||
$baseUrl = substr($this->baseUrl, 0, -5);
|
||||
|
||||
$client = new Client;
|
||||
@@ -172,11 +169,10 @@ class FeatureContext implements Context {
|
||||
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
|
||||
*/
|
||||
public function createsABoardNamedWithColor($title, $color) {
|
||||
|
||||
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
|
||||
'title' => $title,
|
||||
'color' => $color
|
||||
]
|
||||
'title' => $title,
|
||||
'color' => $color
|
||||
]
|
||||
);
|
||||
$response = json_decode($this->response->getBody()->getContents(), true);
|
||||
$this->lastInsertIds[$title] = $response['id'];
|
||||
@@ -190,5 +186,4 @@ class FeatureContext implements Context {
|
||||
$id = $this->lastInsertIds[$boardName];
|
||||
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/'.$id, []);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user