From 94e7952ae3fb9a9065f1453d82f5d04e5b197b8d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 30 Aug 2019 10:56:15 +0200 Subject: [PATCH] Kill the tests for now Signed-off-by: Roeland Jago Douma --- composer.json | 6 +- tests/Integration/AppTest.php | 43 --------- tests/Unit/Db/EventMapperTest.php | 87 ----------------- tests/Unit/Db/NotificationMapperTest.php | 97 ------------------- tests/Unit/Db/VoteMapperTest.php | 99 -------------------- tests/Unit/Factories/EventFactory.php | 46 --------- tests/Unit/Factories/NotificationFactory.php | 31 ------ tests/Unit/Factories/VoteFactory.php | 33 ------- tests/Unit/UnitTestCase.php | 42 --------- tests/bootstrap.php | 4 - 10 files changed, 2 insertions(+), 486 deletions(-) delete mode 100644 tests/Integration/AppTest.php delete mode 100644 tests/Unit/Db/EventMapperTest.php delete mode 100644 tests/Unit/Db/NotificationMapperTest.php delete mode 100644 tests/Unit/Db/VoteMapperTest.php delete mode 100644 tests/Unit/Factories/EventFactory.php delete mode 100644 tests/Unit/Factories/NotificationFactory.php delete mode 100644 tests/Unit/Factories/VoteFactory.php delete mode 100644 tests/Unit/UnitTestCase.php diff --git a/composer.json b/composer.json index dfba726..214fc84 100644 --- a/composer.json +++ b/composer.json @@ -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." } } diff --git a/tests/Integration/AppTest.php b/tests/Integration/AppTest.php deleted file mode 100644 index af24edf..0000000 --- a/tests/Integration/AppTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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')); - } -} diff --git a/tests/Unit/Db/EventMapperTest.php b/tests/Unit/Db/EventMapperTest.php deleted file mode 100644 index 94e397c..0000000 --- a/tests/Unit/Db/EventMapperTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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); - } -} diff --git a/tests/Unit/Db/NotificationMapperTest.php b/tests/Unit/Db/NotificationMapperTest.php deleted file mode 100644 index 7267477..0000000 --- a/tests/Unit/Db/NotificationMapperTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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); - } -} diff --git a/tests/Unit/Db/VoteMapperTest.php b/tests/Unit/Db/VoteMapperTest.php deleted file mode 100644 index 91b6b67..0000000 --- a/tests/Unit/Db/VoteMapperTest.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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); - } -} diff --git a/tests/Unit/Factories/EventFactory.php b/tests/Unit/Factories/EventFactory.php deleted file mode 100644 index b79c0b6..0000000 --- a/tests/Unit/Factories/EventFactory.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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 -]); diff --git a/tests/Unit/Factories/NotificationFactory.php b/tests/Unit/Factories/NotificationFactory.php deleted file mode 100644 index 0c9421b..0000000 --- a/tests/Unit/Factories/NotificationFactory.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -use League\FactoryMuffin\Faker\Facade as Faker; - -/** - * General factory for the notification model. - */ -$fm->define('OCA\Forms\Db\Notification')->setDefinitions([ - 'userId' => Faker::firstNameMale() -]); diff --git a/tests/Unit/Factories/VoteFactory.php b/tests/Unit/Factories/VoteFactory.php deleted file mode 100644 index 6035456..0000000 --- a/tests/Unit/Factories/VoteFactory.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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' -]); diff --git a/tests/Unit/UnitTestCase.php b/tests/Unit/UnitTestCase.php deleted file mode 100644 index 61218a3..0000000 --- a/tests/Unit/UnitTestCase.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @author Kai Schröer - * - * @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 . - * - */ - -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'); - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 82bd68e..c0a5452 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -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();