Browse Source

Fixed coding standards issues.

pull/396/head
Christian Selig 11 years ago
parent
commit
86d85e96d2
  1. 4
      includes/utilities.inc
  2. 41
      islandora.module
  3. 151
      tests/islandora_tuque.test

4
includes/utilities.inc

@ -916,9 +916,9 @@ function islandora_as_renderable_array(&$markup_array) {
/** /**
* Creates and returns a singleton of tuque if one does not already exist. * Creates and returns a singleton of tuque if one does not already exist.
* *
* @param object $user * @param object $user
* User who created the request. * User who created the request.
* @param object $url * @param object $url
* URL to Fedora. * URL to Fedora.
* *
* @return IslandoraTuque * @return IslandoraTuque

41
islandora.module

@ -998,36 +998,6 @@ function islandora_get_tuque_connection($new_user = NULL, $url = NULL) {
global $user; global $user;
// $user_for_tuque = NULL;
//
// if TUQUE DOES NOT EXIST {
// if PROVIDED USER IS NOT NULL {
// MAKE TUQUE WITH PROVIDED USER
// }
// else
// {
// MAKE TUQUE WITH GLOBAL USER
// }
// }
// else {
// if PROVIDED USER IS NOT NULL {
// if PROVIDED USER IS NOT TUQUE'S USER {
// MAKE TUQUE WITH PROVIDED USER
// }
// else {
// LEAVE TUQUE ALONE
// }
// }
// else {
// if GLOBAL USER IS NOT TUQUE'S USER {
// MAKE TUQUE WITH GLOBAL USER
// }
// else {
// LEAVE TUQUE ALONE
// }
// }
// }
// If tuque is NULL. // If tuque is NULL.
if (!$tuque) { if (!$tuque) {
// If the provided user is not null, pass it along to Tuque. // If the provided user is not null, pass it along to Tuque.
@ -1067,6 +1037,17 @@ function islandora_get_tuque_connection($new_user = NULL, $url = NULL) {
return $tuque; return $tuque;
} }
/**
* Creates a singleton of tuque.
*
* @param object $user
* The user to create tuque with.
* @param string $url
* The URL to create tuque with.
*
* @return IslandoraTuque
* The singleton tuque object.
*/
function islandora_make_tuque($user, $url) { function islandora_make_tuque($user, $url) {
if (IslandoraTuque::exists()) { if (IslandoraTuque::exists()) {
try { try {

151
tests/islandora_tuque.test

@ -58,93 +58,90 @@ class IslandoraTuqueTestCase extends IslandoraWebTestCase {
} }
/** /**
* Tests that tuque does not exist and the user is not null. * Tests that tuque does not exist and the user is not null.
*/ */
public function testTuqueDoesNotExistAndUserIsNotNull() { public function testTuqueDoesNotExistAndUserIsNotNull() {
$tuque = &drupal_static(__FUNCTION__); $tuque = &drupal_static(__FUNCTION__);
$tuque = NULL; $tuque = NULL;
$user_to_provide = user_load(0);
$new_tuque = islandora_get_tuque_connection($user_to_provide); $user_to_provide = user_load(0);
$new_tuque_user_name = $new_tuque->connection->username;
assertNotNull($new_tuque); $new_tuque = islandora_get_tuque_connection($user_to_provide);
assertNotNull($tuque); $new_tuque_user_name = $new_tuque->connection->username;
assertEqual($user_to_provide->name, $new_tuque_user_name);
}
/** assertNotNull($new_tuque);
* Tests that tuque does not exist and the user is null. assertNotNull($tuque);
*/ assertEqual($user_to_provide->name, $new_tuque_user_name);
public function testTuqueDoesNotExistAndUserIsNull() { }
$tuque = &drupal_static(__FUNCTION__);
$tuque = NULL;
$user_to_provide = NULL; /**
* Tests that tuque does not exist and the user is null.
*/
public function testTuqueDoesNotExistAndUserIsNull() {
$tuque = &drupal_static(__FUNCTION__);
$tuque = NULL;
$new_tuque = islandora_get_tuque_connection($user_to_provide); $user_to_provide = NULL;
$new_tuque_user_name = $new_tuque->connection->username;
global $user; $new_tuque = islandora_get_tuque_connection($user_to_provide);
$new_tuque_user_name = $new_tuque->connection->username;
assertNotNull($new_tuque); global $user;
assertNotNull($tuque);
assertEqual($new_tuque_user_name, $user);
}
/** assertNotNull($new_tuque);
* Test that tuque exists and the user is not null and the user is not tuque's assertNotNull($tuque);
* user. assertEqual($new_tuque_user_name, $user);
*/ }
public function testTuqueExistsAndUserIsNotNullAndUserIsNotTuquesUser() {
$tuque = &drupal_static(__FUNCTION__);
$user_to_provide = user_load(0);
$new_tuque = islandora_get_tuque_connection($user_to_provide);
assertNotNull($new_tuque);
assertNotNull($tuque);
assertNotEqual($user_to_provide->name, $new_tuque->connection->username);
}
/** /**
* Tests that tuque exists and the user is not null and the user is tuque's user * Test that tuque exists, the user is not null, the user is not tuque's user.
*/ */
public function testTuqueExistsAndUserIsNotNullAndUserIsTuquesUser() { public function testTuqueExistsAndUserIsNotNullAndUserIsNotTuquesUser() {
$tuque = &drupal_static(__FUNCTION__); $tuque = &drupal_static(__FUNCTION__);
$new_tuque = islandora_get_tuque_connection($tuque->connection->username); $user_to_provide = user_load(0);
$new_tuque = islandora_get_tuque_connection($user_to_provide);
assertNotNull($new_tuque);
assertNotNull($tuque);
assertNotEqual($user_to_provide->name, $new_tuque->connection->username);
}
assertNotNull($new_tuque); /**
assertNotNull($tuque); * Tests that tuque exists, the user is not null, the user is tuque's user.
assertEqual($tuque->connection->username, $new_tuque->connection->username); */
} public function testTuqueExistsAndUserIsNotNullAndUserIsTuquesUser() {
$tuque = &drupal_static(__FUNCTION__);
$new_tuque = islandora_get_tuque_connection($tuque->connection->username);
/** assertNotNull($new_tuque);
* Tests that tuque exists and the user is null and the global user is not assertNotNull($tuque);
* tuque's user. assertEqual($tuque->connection->username, $new_tuque->connection->username);
*/ }
public function testTuqueExistsAndUserIsNullAndGlobalUserIsNotTuquesUser() {
$tuque = &drupal_static(__FUNCTION__);
global $user = NULL;
$new_tuque = islandora_get_tuque_connection($user);
assertNotNull($new_tuque);
assertNotNull($tuque);
assertNotEqual($new_tuque->connection->username, $user);
}
/** /**
* Tests that tuque exists and the user is null and the global user is tuque's * Tests that tuque exists, the user is null, global user is not tuque's user.
* user. */
*/ public function testTuqueExistsAndUserIsNullAndGlobalUserIsNotTuquesUser() {
public function testTuqueExistsAndUserIsNullAndGlobalUserIsTuquesUser() { $tuque = &drupal_static(__FUNCTION__);
$tuque = &drupal_static(__FUNCTION__); global $user = NULL;
global $user = $tuque->connection->username; $new_tuque = islandora_get_tuque_connection($user);
$new_tuque = islandora_get_tuque_connection($user);
assertNotNull($new_tuque);
assertNotNull($new_tuque); assertNotNull($tuque);
assertNotNull($tuque); assertNotEqual($new_tuque->connection->username, $user);
assertEqual($new_tuque->connection->username, $user); }
}
/**
* Tests that tuque exists, the user is null, global user is tuque's user.
*/
public function testTuqueExistsAndUserIsNullAndGlobalUserIsTuquesUser() {
$tuque = &drupal_static(__FUNCTION__);
global $_islandora_user;
$_islandora_user = $tuque->connection->username;
$new_tuque = islandora_get_tuque_connection($user);
assertNotNull($new_tuque);
assertNotNull($tuque);
assertEqual($new_tuque->connection->username, $user);
}

Loading…
Cancel
Save