Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobia De Koninck <tobia@ledfan.be>2017-07-29 14:54:55 +0300
committerTobia De Koninck <tobia@ledfan.be>2017-07-29 14:54:58 +0300
commitbcad36c33adbade5dd84ba6ef2a38969e36fe53e (patch)
tree08d1c6d9b7aff045b8c45eb35ca4ca90c64834d5
parentb545ff132caa0a5f183787ea5f864bb76ae4ef08 (diff)
Fix tests and styling
-rw-r--r--lib/Migration/RefreshRoster.php14
-rw-r--r--lib/rosterpush.php16
-rw-r--r--tests/unit/stanzahandlers/IQTest.php14
3 files changed, 29 insertions, 15 deletions
diff --git a/lib/Migration/RefreshRoster.php b/lib/Migration/RefreshRoster.php
index 09d579e..244a1b5 100644
--- a/lib/Migration/RefreshRoster.php
+++ b/lib/Migration/RefreshRoster.php
@@ -8,7 +8,8 @@ use OCP\ILogger;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-class RefreshRoster implements IRepairStep {
+class RefreshRoster implements IRepairStep
+{
/**
* @var RosterPush
@@ -32,7 +33,8 @@ class RefreshRoster implements IRepairStep {
* @param IConfig $config
* @param ILogger $logger
*/
- public function __construct(RosterPush $rosterPush, IConfig $config, ILogger $logger) {
+ public function __construct(RosterPush $rosterPush, IConfig $config, ILogger $logger)
+ {
$this->rosterPush = $rosterPush;
$this->config = $config;
$this->logger = $logger;
@@ -43,7 +45,8 @@ class RefreshRoster implements IRepairStep {
*
* @return string
*/
- public function getName() {
+ public function getName()
+ {
return "Refresh the roster of all users when the app has been installed before.";
}
@@ -54,7 +57,8 @@ class RefreshRoster implements IRepairStep {
* @param IOutput $output
* @throws \Exception in case of failure
*/
- public function run(IOutput $output) {
+ public function run(IOutput $output)
+ {
if ($this->config->getAppValue('ojsxc', 'serverType') === 'internal') {
$stats = $this->rosterPush->refreshRoster();
$output->info("Updated " . $stats["updated"] . " roster items");
@@ -63,4 +67,4 @@ class RefreshRoster implements IRepairStep {
$this->logger->info("Removed " . $stats["removed"] . " roster items", ["app" => "OJSXC"]);
}
}
-} \ No newline at end of file
+}
diff --git a/lib/rosterpush.php b/lib/rosterpush.php
index 7587f1c..46fe3ea 100644
--- a/lib/rosterpush.php
+++ b/lib/rosterpush.php
@@ -88,7 +88,8 @@ class RosterPush
* user which was ever deleted. The deleted user is fetched from the
* `addressbookchanges` table.
*/
- public function refreshRoster() {
+ public function refreshRoster()
+ {
$stats = [
"updated" => 0,
"removed" => 0
@@ -101,13 +102,12 @@ class RosterPush
}
/**
- * Here we look into the addressbookchanges table for deletions
- * of "contacts" in the system addressbook. This are actual users of the
- * Nextcloud instance. Because this is a private API of Nextcloud it's
- * encapsulated in a try/catch block.
- */
+ * Here we look into the addressbookchanges table for deletions
+ * of "contacts" in the system addressbook. This are actual users of the
+ * Nextcloud instance. Because this is a private API of Nextcloud it's
+ * encapsulated in a try/catch block.
+ */
try {
-
$query = "SELECT `id` FROM `*PREFIX*addressbooks` WHERE `principaluri`='principals/system/system' LIMIT 1";
$addressbooks = \OC::$server->getDatabaseConnection()->executeQuery($query)->fetchAll();
$id = $addressbooks[0]['id'];
@@ -125,12 +125,10 @@ class RosterPush
$this->removeRosterItem($userid);
$stats["removed"]++;
}
-
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e);
}
return $stats;
-
}
}
diff --git a/tests/unit/stanzahandlers/IQTest.php b/tests/unit/stanzahandlers/IQTest.php
index 8ab22be..6c15c56 100644
--- a/tests/unit/stanzahandlers/IQTest.php
+++ b/tests/unit/stanzahandlers/IQTest.php
@@ -3,6 +3,7 @@
namespace OCA\OJSXC\StanzaHandlers;
use OCA\OJSXC\Db\IQRoster;
+use OCP\IConfig;
use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit_Framework_TestCase;
@@ -29,12 +30,18 @@ class IQTest extends PHPUnit_Framework_TestCase
*/
private $host;
+ /**
+ * @var PHPUnit_Framework_MockObject_MockObject | IConfig
+ */
+ private $config;
+
public function setUp()
{
$this->host = 'localhost';
$this->userId = 'john';
$this->userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
- $this->iq = new IQ($this->userId, $this->host, $this->userManager);
+ $this->config = $this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock();
+ $this->iq = new IQ($this->userId, $this->host, $this->userManager, $this->config);
}
public function iqRosterProvider()
@@ -144,6 +151,11 @@ class IQTest extends PHPUnit_Framework_TestCase
*/
public function testIqRoster(array $stanza, array $users, $searchCount, $expected)
{
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('debug')
+ ->will($this->returnValue(false));
+
$this->userManager->expects($searchCount)
->method('search')
->with('')