diff --git a/phpunit.integration.xml b/phpunit.integration.xml
index 07fb64e..e57bc4b 100644
--- a/phpunit.integration.xml
+++ b/phpunit.integration.xml
@@ -2,21 +2,16 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
+ colors="true"
>
- ./tests/integration
+ tests/Integration
- lib/db
- lib/dblock.php
- lib/memlock.php
- lib/User.php
- lib/ContactsStoreUserProvider.php
- lib/UserManagerUserProvider.php
- lib/rosterpush.php
+ lib
diff --git a/phpunit.xml b/phpunit.xml
index b6bced8..09b416d 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -2,26 +2,16 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
+ colors="true"
>
- ./tests/unit
+ tests/unit
lib
-
- lib/ContactsMenu
- lib/db
-
- lib/ilock.php
- lib/memlock.php
- lib/dblock.php
-
- lib/command/refreshroster.php
- lib/Migration/RefreshRoster.php
-
diff --git a/tests/integration/ContactsStoreUserProviderTest.php b/tests/Integration/ContactsStoreUserProviderTest.php
similarity index 99%
rename from tests/integration/ContactsStoreUserProviderTest.php
rename to tests/Integration/ContactsStoreUserProviderTest.php
index 0073c17..1c9bb91 100644
--- a/tests/integration/ContactsStoreUserProviderTest.php
+++ b/tests/Integration/ContactsStoreUserProviderTest.php
@@ -1,6 +1,6 @@
container = $app->getContainer();
-
- $version = \OC::$server->getSession()->get('OC_Version');
- if ($version[0] === 8 && $version[1] == 0) {
- $this->markTestSkipped();
- }
}
/**
@@ -62,7 +57,8 @@ class MemLockTest extends TestCase
if ($cache->isAvailable()) {
$this->memCache = $cache->create('ojsxc');
} else {
- die('No memcache available');
+ $this->markTestSkipped();
+ return;
}
$this->memLock = new MemLock(
diff --git a/tests/integration/RosterPushTest.php b/tests/Integration/RosterPushTest.php
similarity index 99%
rename from tests/integration/RosterPushTest.php
rename to tests/Integration/RosterPushTest.php
index b6b9e43..c9c5fe9 100644
--- a/tests/integration/RosterPushTest.php
+++ b/tests/Integration/RosterPushTest.php
@@ -1,6 +1,6 @@
assertEquals($user1->getFullName(), 'Test123');
+ $this->assertEquals($user1->getUid(), '_ojsxc_esc_space_test_ojsxc_esc_space__ojsxc_esc_at__ojsxc_esc_space__ojsxc_squote_space_abc');
+ $user1->setUid('test1');
+ $user1->setFullName('test2');
+ $this->assertEquals($user1->getUid(), 'test1');
+ $this->assertEquals($user1->getFullName(), 'test2');
+ }
+}
diff --git a/utility/mappertestutility.php b/tests/Utility/MapperTestUtility.php
similarity index 79%
rename from utility/mappertestutility.php
rename to tests/Utility/MapperTestUtility.php
index bcfc41c..ef07d03 100644
--- a/utility/mappertestutility.php
+++ b/tests/Utility/MapperTestUtility.php
@@ -1,13 +1,14 @@
overwriteApplicationService($app, 'Host','localhost');
+ $this->overwriteApplicationService($app, 'Host', 'localhost');
$this->overwriteApplicationService($app, 'UserId', 'admin');
$this->container = $app->getContainer();
$this->mapper = $this->container[$this->mapperName];
@@ -38,18 +39,21 @@ class MapperTestUtility extends TestCase {
$con->executeQuery('DELETE FROM ' . $this->mapper->getTableName());
}
- protected function tearDown(): void {
+ protected function tearDown(): void
+ {
$con = $this->container->getServer()->getDatabaseConnection();
$con->executeQuery('DELETE FROM ' . $this->mapper->getTableName());
}
- protected function fetchAll(){
+ protected function fetchAll()
+ {
$con = $this->container->getServer()->getDatabaseConnection();
$stmt = $con->executeQuery('SELECT * FROM ' . $this->mapper->getTableName());
$entities = [];
- while($row = $stmt->fetch()){
- $entities[] = call_user_func($this->entityName . '::fromRow', $row);;
+ while ($row = $stmt->fetch()) {
+ $entities[] = call_user_func($this->entityName . '::fromRow', $row);
+ ;
}
$stmt->closeCursor();
@@ -57,7 +61,8 @@ class MapperTestUtility extends TestCase {
return $entities;
}
- protected function fetchAllAsArray($tableName = null){
+ protected function fetchAllAsArray($tableName = null)
+ {
if (is_null($tableName)) {
$tableName = $this->mapper->getTableName();
} else {
@@ -66,7 +71,7 @@ class MapperTestUtility extends TestCase {
$stmt = $con->executeQuery('SELECT * FROM ' . $tableName);
$result = [];
- while($row = $stmt->fetch()){
+ while ($row = $stmt->fetch()) {
$result[] = $row;
}
$stmt->closeCursor();
@@ -74,9 +79,8 @@ class MapperTestUtility extends TestCase {
return $result;
}
- public function getLastInsertedId() {
+ public function getLastInsertedId()
+ {
return $this->container->getServer()->getDatabaseConnection()->lastInsertId();
-
}
-
}
diff --git a/utility/testcase.php b/tests/Utility/TestCase.php
similarity index 90%
rename from utility/testcase.php
rename to tests/Utility/TestCase.php
index d733e52..a5caa8e 100644
--- a/utility/testcase.php
+++ b/tests/Utility/TestCase.php
@@ -1,22 +1,22 @@
parse("" . $expected . "");
$parsedActual = $service->parse("" . $actual . "");
self::assertEquals($parsedExpected, $parsedActual, 'Failed asserting that two XML strings are equal.');
-
}
/**
@@ -24,7 +24,8 @@ class TestCase extends CoreTestCase {
* @param Entity[] $actual
* @param array $fields Use camelCase for this instead of snake_case!
*/
- public static function assertObjectDbResultsEqual($expected, $actual, array $fields) {
+ public static function assertObjectDbResultsEqual($expected, $actual, array $fields)
+ {
$expectedArray = [];
$actualArray = [];
@@ -39,7 +40,8 @@ class TestCase extends CoreTestCase {
self::assertArrayDbResultsEqual($expectedArray, $actualArray, $fields);
}
- public static function assertArrayDbResultsEqual(array $expected, array $actual, array $fields) {
+ public static function assertArrayDbResultsEqual(array $expected, array $actual, array $fields)
+ {
$expectedFiltered = [];
$actualFiltered = [];
@@ -64,10 +66,10 @@ class TestCase extends CoreTestCase {
self::assertCount(count($expected), $actual);
self::assertEquals($expectedFiltered, $actualFiltered);
-
}
- public function overwriteApplicationService(Application $app, $name, $newService) {
+ public function overwriteApplicationService(Application $app, $name, $newService)
+ {
$app->getContainer()->registerService($name, function () use ($newService) {
return $newService;
});
@@ -79,12 +81,12 @@ class TestCase extends CoreTestCase {
* @param $name
* @param $newValue
*/
- public function setValueOfPrivateProperty($obj, $name, $newValue) {
+ public function setValueOfPrivateProperty($obj, $name, $newValue)
+ {
$refl = new \ReflectionObject($obj);
$p = $refl->getProperty($name);
$p->setAccessible(true);
$p->setValue($obj, $newValue);
$p->setAccessible(false);
}
-
-}
\ No newline at end of file
+}
diff --git a/tests/bootstrap-integration.php b/tests/bootstrap-integration.php
index f415af9..a5aebe5 100644
--- a/tests/bootstrap-integration.php
+++ b/tests/bootstrap-integration.php
@@ -1,13 +1,11 @@
addPsr4('OCA\\OJSXC\\Tests\\', __DIR__, true);