diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-05 15:23:59 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-05 15:23:59 +0100 |
commit | 4c5e27bc13ce1f5132bd14af3c77bde758ae3a24 (patch) | |
tree | 37c289d81eb969f87b8152385bb8d9a0d6bf973a /tests/integration/bootstrap.php | |
parent | 74e823f1f9ca55ab7a33dabe3e09fec2cafc35c6 (diff) |
first integration test
Diffstat (limited to 'tests/integration/bootstrap.php')
-rw-r--r-- | tests/integration/bootstrap.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php new file mode 100644 index 000000000..b57e14e58 --- /dev/null +++ b/tests/integration/bootstrap.php @@ -0,0 +1,46 @@ +<?php +namespace OCA\News\Tests\Integration; + +require_once __DIR__ . '/../../../../lib/base.php'; + + +class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { + + protected $userId = 'test'; + + protected function setupNewsDatabase($user='test') { + $db = \OC::$server->getDb(); + $sql = [ + 'DELETE FROM *PREFIX*news_items WHERE feed_id IN ' . + '(SELECT id FROM *PREFIX*news_feeds WHERE user_id = ?)', + 'DELETE FROM *PREFIX*news_feeds WHERE user_id = ?', + 'DELETE FROM *PREFIX*news_folders WHERE user_id = ?' + ]; + + foreach ($sql as $query) { + $db->prepareQuery($query)->execute($user); + } + } + + + protected function setupUser($user='test') { + $userManager = \OC::$server->getUserManager(); + + if ($userManager->userExists($user)) { + $userManager->delete($user); + } + + $userManager->createUser('test', 'test'); + + $session = \OC::$server->getUserSession(); + $session->setUser($userManager->get($user)); + } + + + protected function setUp($user='test') { + $this->setupUser($user); + $this->setupNewsDatabase($user); + } + + +}
\ No newline at end of file |