jonathangreen
11 years ago
5 changed files with 224 additions and 8 deletions
@ -0,0 +1,147 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Tests islandora tuque functionality. |
||||
*/ |
||||
|
||||
class IslandoraTuqueTestCase extends IslandoraWebTestCase { |
||||
|
||||
/** |
||||
* Gets info to display to describe this test. |
||||
* |
||||
* @see IslandoraWebTestCase::getInfo() |
||||
*/ |
||||
public static function getInfo() { |
||||
return array( |
||||
'name' => 'Islandora Tuque', |
||||
'description' => 'Tests basic tuque functionality.', |
||||
'group' => 'Islandora', |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Prepares enviroment for testing. |
||||
* |
||||
* @see IslandoraWebTestCase::setUp() |
||||
*/ |
||||
public function setUp() { |
||||
parent::setUp(array('islandora')); |
||||
} |
||||
|
||||
/** |
||||
* Tests that a new tuque instance is created when a new user is provided. |
||||
*/ |
||||
public function testTuqueUserChange() { |
||||
global $user; |
||||
|
||||
$tuque = islandora_get_tuque_connection($user); |
||||
|
||||
$old_user_name = $tuque->connection->username; |
||||
|
||||
$new_user = user_load(0); |
||||
|
||||
$tuque = islandora_get_tuque_connection($new_user); |
||||
|
||||
$new_user_name = $tuque->connection->username; |
||||
|
||||
$this->assertNotEqual($old_user_name, $new_user_name, "User in tuque's connection changes when a new user is provided to islandora_get_tuque_connection()."); |
||||
|
||||
$old_user_name = $new_user_name; |
||||
|
||||
$tuque = islandora_get_tuque_connection(); |
||||
|
||||
$new_user_name = $tuque->connection->username; |
||||
|
||||
$this->assertEqual($old_user_name, $new_user_name, "User in tuque's connection does not change when no user is provided to islandora_get_tuque_connection()."); |
||||
} |
||||
|
||||
/** |
||||
* Tests that tuque does not exist and the user is not null. |
||||
*/ |
||||
public function testTuqueDoesNotExistAndUserIsNotNull() { |
||||
$tuque = &drupal_static(__FUNCTION__); |
||||
$tuque = NULL; |
||||
|
||||
$user_to_provide = user_load(0); |
||||
|
||||
$new_tuque = islandora_get_tuque_connection($user_to_provide); |
||||
$new_tuque_user_name = $new_tuque->connection->username; |
||||
|
||||
assertNotNull($new_tuque); |
||||
assertNotNull($tuque); |
||||
assertEqual($user_to_provide->name, $new_tuque_user_name); |
||||
} |
||||
|
||||
/** |
||||
* Tests that tuque does not exist and the user is null. |
||||
*/ |
||||
public function testTuqueDoesNotExistAndUserIsNull() { |
||||
$tuque = &drupal_static(__FUNCTION__); |
||||
$tuque = NULL; |
||||
|
||||
$user_to_provide = NULL; |
||||
|
||||
$new_tuque = islandora_get_tuque_connection($user_to_provide); |
||||
$new_tuque_user_name = $new_tuque->connection->username; |
||||
|
||||
global $user; |
||||
|
||||
assertNotNull($new_tuque); |
||||
assertNotNull($tuque); |
||||
assertEqual($new_tuque_user_name, $user); |
||||
} |
||||
|
||||
/** |
||||
* Test that tuque exists, the user is not null, the user is not tuque's 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, the user is not null, the user is tuque's user. |
||||
*/ |
||||
public function testTuqueExistsAndUserIsNotNullAndUserIsTuquesUser() { |
||||
$tuque = &drupal_static(__FUNCTION__); |
||||
$new_tuque = islandora_get_tuque_connection($tuque->connection->username); |
||||
|
||||
assertNotNull($new_tuque); |
||||
assertNotNull($tuque); |
||||
assertEqual($tuque->connection->username, $new_tuque->connection->username); |
||||
} |
||||
|
||||
/** |
||||
* Tests that tuque exists, the user is null, global user is not tuque's user. |
||||
*/ |
||||
public function testTuqueExistsAndUserIsNullAndGlobalUserIsNotTuquesUser() { |
||||
$tuque = &drupal_static(__FUNCTION__); |
||||
global $user; |
||||
$user = NULL; |
||||
$new_tuque = islandora_get_tuque_connection($user); |
||||
|
||||
assertNotNull($new_tuque); |
||||
assertNotNull($tuque); |
||||
assertNotEqual($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…
Reference in new issue