Merge pull request #57 from nextcloud/tests/kill_them
Kill the tests for now
This commit is contained in:
commit
17ad526e29
|
@ -14,9 +14,7 @@
|
|||
}
|
||||
],
|
||||
"require-dev": {
|
||||
"christophwurst/nextcloud": "^15.0",
|
||||
"phpunit/phpunit": "^5.4",
|
||||
"league/factory-muffin": "^3.0",
|
||||
"league/factory-muffin-faker": "^2.0"
|
||||
"christophwurst/nextcloud": "^16.0",
|
||||
"phpunit/phpunit": "^7."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Forms\Tests\Integration;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AppTest extends TestCase {
|
||||
|
||||
private $container;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$app = new App('forms');
|
||||
$this->container = $app->getContainer();
|
||||
}
|
||||
|
||||
public function testAppInstalled() {
|
||||
$appManager = $this->container->query('OCP\App\IAppManager');
|
||||
$this->assertTrue($appManager->isInstalled('forms'));
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Forms\Tests\Unit\Db;
|
||||
|
||||
use OCA\Forms\Db\Event;
|
||||
use OCA\Forms\Db\EventMapper;
|
||||
use OCA\Forms\Tests\Unit\UnitTestCase;
|
||||
use OCP\IDBConnection;
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
class EventMapperTest extends UnitTestCase {
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $con;
|
||||
/** @var EventMapper */
|
||||
private $eventMapper;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->con = \OC::$server->getDatabaseConnection();
|
||||
$this->eventMapper = new EventMapper($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create some fake data and persist them to the database.
|
||||
*
|
||||
* @return Event
|
||||
*/
|
||||
public function testCreate() {
|
||||
/** @var Event $event */
|
||||
$event = $this->fm->instance('OCA\Forms\Db\Event');
|
||||
$this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the previously created entry and persist the changes.
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param Event $event
|
||||
* @return Event
|
||||
*/
|
||||
public function testUpdate(Event $event) {
|
||||
$newTitle = Faker::sentence(10);
|
||||
$newDescription = Faker::paragraph();
|
||||
$event->setTitle($newTitle());
|
||||
$event->setDescription($newDescription());
|
||||
$this->eventMapper->update($event);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the previously created entry from the database.
|
||||
*
|
||||
* @depends testUpdate
|
||||
* @param Event $event
|
||||
*/
|
||||
public function testDelete(Event $event) {
|
||||
$this->eventMapper->delete($event);
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Forms\Tests\Unit\Db;
|
||||
|
||||
use OCA\Forms\Db\Event;
|
||||
use OCA\Forms\Db\EventMapper;
|
||||
use OCA\Forms\Db\Notification;
|
||||
use OCA\Forms\Db\NotificationMapper;
|
||||
use OCA\Forms\Tests\Unit\UnitTestCase;
|
||||
use OCP\IDBConnection;
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
class NotificationMapperTest extends UnitTestCase {
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $con;
|
||||
/** @var NotificationMapper */
|
||||
private $notificationMapper;
|
||||
/** @var EventMapper */
|
||||
private $eventMapper;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->con = \OC::$server->getDatabaseConnection();
|
||||
$this->notificationMapper = new NotificationMapper($this->con);
|
||||
$this->eventMapper = new EventMapper($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create some fake data and persist them to the database.
|
||||
*
|
||||
* @return Notification
|
||||
*/
|
||||
public function testCreate() {
|
||||
/** @var Event $event */
|
||||
$event = $this->fm->instance('OCA\Forms\Db\Event');
|
||||
$this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
|
||||
|
||||
/** @var Notification $notification */
|
||||
$notification = $this->fm->instance('OCA\Forms\Db\Notification');
|
||||
$notification->setFormId($event->getId());
|
||||
$this->assertInstanceOf(Notification::class, $this->notificationMapper->insert($notification));
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the previously created entry and persist the changes.
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param Notification $notification
|
||||
* @return Notification
|
||||
*/
|
||||
public function testUpdate(Notification $notification) {
|
||||
$newUserId = Faker::firstNameMale();
|
||||
$notification->setUserId($newUserId());
|
||||
$this->notificationMapper->update($notification);
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the previously created entries from the database.
|
||||
*
|
||||
* @depends testUpdate
|
||||
* @param Notification $notification
|
||||
*/
|
||||
public function testDelete(Notification $notification) {
|
||||
$event = $this->eventMapper->find($notification->getFormId());
|
||||
$this->notificationMapper->delete($notification);
|
||||
$this->eventMapper->delete($event);
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Forms\Tests\Unit\Db;
|
||||
|
||||
use OCA\Forms\Db\Event;
|
||||
use OCA\Forms\Db\EventMapper;
|
||||
use OCA\Forms\Db\Vote;
|
||||
use OCA\Forms\Db\VoteMapper;
|
||||
use OCA\Forms\Tests\Unit\UnitTestCase;
|
||||
use OCP\IDBConnection;
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
class VoteMapperTest extends UnitTestCase {
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $con;
|
||||
/** @var VoteMapper */
|
||||
private $voteMapper;
|
||||
/** @var EventMapper */
|
||||
private $eventMapper;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->con = \OC::$server->getDatabaseConnection();
|
||||
$this->voteMapper = new VoteMapper($this->con);
|
||||
$this->eventMapper = new EventMapper($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create some fake data and persist them to the database.
|
||||
*
|
||||
* @return Vote
|
||||
*/
|
||||
public function testCreate() {
|
||||
/** @var Event $event */
|
||||
$event = $this->fm->instance('OCA\Forms\Db\Event');
|
||||
$this->assertInstanceOf(Event::class, $this->eventMapper->insert($event));
|
||||
|
||||
|
||||
/** @var Vote $vote */
|
||||
$vote = $this->fm->instance('OCA\Forms\Db\Vote');
|
||||
$vote->setFormId($event->getId());
|
||||
$vote->setVoteOptionId(1);
|
||||
$this->assertInstanceOf(Vote::class, $this->voteMapper->insert($vote));
|
||||
|
||||
return $vote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the previously created entry and persist the changes.
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param Vote $vote
|
||||
* @return Vote
|
||||
*/
|
||||
public function testUpdate(Vote $vote) {
|
||||
$newVoteOptionText = Faker::date('Y-m-d H:i:s');
|
||||
$vote->setVoteOptionText($newVoteOptionText());
|
||||
$this->voteMapper->update($vote);
|
||||
|
||||
return $vote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the previously created entries from the database.
|
||||
*
|
||||
* @depends testUpdate
|
||||
* @param Vote $vote
|
||||
*/
|
||||
public function testDelete(Vote $vote) {
|
||||
$event = $this->eventMapper->find($vote->getFormId());
|
||||
$this->voteMapper->delete($vote);
|
||||
$this->eventMapper->delete($event);
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
/**
|
||||
* General factory for the event model.
|
||||
*/
|
||||
$fm->define('OCA\Forms\Db\Event')->setDefinitions([
|
||||
'type' => 0,
|
||||
'title' => Faker::sentence(10),
|
||||
'description' => Faker::text(255),
|
||||
'owner' => Faker::firstNameMale(),
|
||||
'created' => function() {
|
||||
$date = new DateTime('today');
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
},
|
||||
'access' => 'registered',
|
||||
'expire' => function() {
|
||||
$date = new DateTime('tomorrow');
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
},
|
||||
'hash' => Faker::regexify('[A-Za-z0-9]{16}'),
|
||||
'isAnonymous' => 0,
|
||||
'fullAnonymous' => 0
|
||||
]);
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
/**
|
||||
* General factory for the notification model.
|
||||
*/
|
||||
$fm->define('OCA\Forms\Db\Notification')->setDefinitions([
|
||||
'userId' => Faker::firstNameMale()
|
||||
]);
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
/**
|
||||
* General factory for the vote model.
|
||||
*/
|
||||
$fm->define('OCA\Forms\Db\Vote')->setDefinitions([
|
||||
'voteOptionText' => Faker::text(255),
|
||||
'userId' => Faker::firstNameMale(),
|
||||
'voteAnswer' => 'yes'
|
||||
]);
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @author Kai Schröer <git@schroeer.co>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Forms\Tests\Unit;
|
||||
|
||||
use League\FactoryMuffin\FactoryMuffin;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
abstract class UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/** @var FactoryMuffin */
|
||||
protected $fm;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->fm = new FactoryMuffin();
|
||||
$this->fm->loadFactories(__DIR__ . '/Factories');
|
||||
}
|
||||
}
|
|
@ -31,8 +31,4 @@ require_once __DIR__ . '/../vendor/autoload.php';
|
|||
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
|
||||
\OC_App::loadApp('forms');
|
||||
|
||||
if (!class_exists('PHPUnit_Framework_TestCase')) {
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
}
|
||||
|
||||
\OC_Hook::clear();
|
||||
|
|
Loading…
Reference in a new issue