From cc726ed4cd63dc62f9e4fd69884e5535f258a3e1 Mon Sep 17 00:00:00 2001 From: qadan Date: Tue, 15 Apr 2014 18:32:51 +0000 Subject: [PATCH 1/8] minor improvements to ingestConstructedObject() --- tests/islandora_web_test_case.inc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index 89ca9cbb..d5830e70 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -315,7 +315,8 @@ class IslandoraWebTestCase extends DrupalWebTestCase { * An array containing object information using these keys: * 'label' - The object label; randomized if not set. * 'pid' - 'namespace:pid', or just 'namespace' to generate the suffix. - * 'models' - An array that can contain multiple content model PIDs. + * 'models' - An array that can contain multiple content model PIDs, or a + * string containing a single content model PID. * 'owner' - The object's owner. Defaults to the currently logged-in user, * if available. It is recommended to set this to a value that can be found * in $this->users; otherwise, this object will have to be manually deleted. @@ -331,8 +332,7 @@ class IslandoraWebTestCase extends DrupalWebTestCase { * FALSE if the object ingest failed, or the object array if successful. */ public function ingestConstructedObject(array $properties = array(), array $datastreams = array()) { - module_load_include('inc', 'islandora', 'includes/tuque'); - $tuque = new IslandoraTuque(); + $tuque = islandora_get_tuque_connection($this->admin); $repository = $tuque->repository; if (!isset($properties['pid'])) { $properties['pid'] = "islandora"; @@ -355,13 +355,14 @@ class IslandoraWebTestCase extends DrupalWebTestCase { $object->owner = $this->loggedInUser->name; } - if (isset($properties['models']) && is_array($properties['models'])) { - foreach ($properties['models'] as $model) { - $object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $model); + if (isset($properties['models'])) { + try { + $object->models = (array) $properties['models']; + } + catch (Exception $e) { + $this->fail("Encountered an exception when trying to add content models to {$object->id}: $e"); + return FALSE; } - } - elseif (isset($properties['models']) && !is_array($properties['models'])) { - $this->fail(t("'models' key of properties variable is not an array. Content model(s) will not be set."), 'Islandora'); } $repository->ingestObject($object); From 95cd45660702164b0e2b12433c933b86956c246e Mon Sep 17 00:00:00 2001 From: qadan Date: Wed, 16 Apr 2014 16:20:40 +0000 Subject: [PATCH 2/8] some functionality i would like also yesplz --- tests/islandora_web_test_case.inc | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index d5830e70..ad670d54 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -443,4 +443,82 @@ QUERY; } } + /** + * These are a few quick helper functions to fill in a gap in the standard + * DrupalWebTestCase where no function exists to test for the simple existence + * or non-existence of an error. + */ + + /** + * Asserts that an error is found in $this->content. + * + * @param string $message + * The message to pass on to the results. + * @param string $group + * The group to place the result in. + * + * @return bool + * TRUE on success, FALSE on failure. + */ + public function assertError($message = '', $group = 'Other') { + if (!$message) { + $message = "Error found on current page when error was expected."; + } + return $this->assertRaw("
", $message, $group); + } + + /** + * Asserts that no error is found in $this->content. + * + * @param string $message + * The message to pass on to the results. + * @param string $group + * The group to place the result in. + * + * @return bool + * TRUE on success, FALSE on failure. + */ + public function assertNoError($message = '', $group = 'Other') { + if (!$message) { + $message = "No error found on current page when no error was expected."; + } + return $this->assertNoRaw("
", $message, $group); + } + + /** + * Asserts that a warning is found in $this->content. + * + * @param string $message + * The message to pass on to the results. + * @param string $group + * The group to place the result in. + * + * @return bool + * TRUE on success, FALSE on failure. + */ + public function assertWarning($message = '', $group = 'Other') { + if (!$message) { + $message = "Warning found on current page when warning was expected."; + } + return $this->assertRaw("
", $message, $group); + } + + /** + * Asserts that no warning is found in $this->content. + * + * @param string $message + * The message to pass on to the results. + * @param string $group + * The group to place the result in. + * + * @return bool + * TRUE on success, FALSE on failure. + */ + public function assertNoWarning($message = '', $group = 'Other') { + if (!$message) { + $message = "No warning found on current page when no warning was expected."; + } + return $this->assertNoRaw("
", $message, $group); + } + } From caf711aa3f066bfeef49c0e54e31ca054cb56b2a Mon Sep 17 00:00:00 2001 From: qadan Date: Mon, 21 Apr 2014 19:57:14 +0000 Subject: [PATCH 3/8] more needed functionality --- tests/islandora_web_test_case.inc | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index ad670d54..51d188cb 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -521,4 +521,54 @@ QUERY; return $this->assertNoRaw("
", $message, $group); } + /** + * Makes a drupalPost() request, using the form submit button's ID. + * + * Because drupalPost() is silly and doesn't let us choose which button we'd + * like to select if multiple buttons have the same value, this function + * allows us to select whatever button we'd like based on the ID instead. + * + * This is done via the absolutely hilarious method of fudging the actual + * button labels that don't have the ID we want, so that the only one left + * with the correct label is the one with the right ID. + * + * @see DrupalWebTestCase::drupalPost(). + * + * @param $path + * Location of the post form. + * @param $edit + * Field data in an associative array. + * @param $submit + * Value of the submit button whose click is to be emulated. + * @param $id + * ID of the submit button whose click is to be emulated. + * @param array $options + * Options to be forwarded to url(). + * @param array $headers + * An array containing additional HTTP request headers, each formatted as + * "name: value". + * @param null $form_html_id + * (optional) HTML ID of the form to be submitted. + * @param null $extra_post + * (optional) A string of additional data to append to the POST submission. + * + * @return bool|string + * The content from the POST request's curlExec, or FALSE on fail. + */ + public function drupalPostByID($path, $edit, $submit, $id, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) { + $buttons = $this->xpath("//input[@type=\"submit\" and @value=\"{$submit}\"]"); + if (empty($buttons)) { + $this->fail("No buttons found on the page with value '$submit'"); + return FALSE; + } + $i = 0; + foreach ($buttons as $button) { + if ($button['id'] !== $id) { + $button['value'] .= "_$i"; + $i++; + } + } + return $this->drupalPost($path, $edit, $submit, $options, $headers, $form_html_id, $extra_post); + } + } From 230e4bd2b4d36875e0198eea3b09951f8d6ce4d5 Mon Sep 17 00:00:00 2001 From: qadan Date: Mon, 21 Apr 2014 18:03:54 -0300 Subject: [PATCH 4/8] Coder fixes --- tests/islandora_web_test_case.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index 51d188cb..329ff53e 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -532,15 +532,15 @@ QUERY; * button labels that don't have the ID we want, so that the only one left * with the correct label is the one with the right ID. * - * @see DrupalWebTestCase::drupalPost(). + * @see DrupalWebTestCase::drupalPost() * - * @param $path + * @param string $path * Location of the post form. - * @param $edit + * @param array $edit * Field data in an associative array. - * @param $submit + * @param string $submit * Value of the submit button whose click is to be emulated. - * @param $id + * @param string $id * ID of the submit button whose click is to be emulated. * @param array $options * Options to be forwarded to url(). From a3d1230e0cdd5bc97b527dbd209cd1bf68262a2f Mon Sep 17 00:00:00 2001 From: qadan Date: Tue, 22 Apr 2014 16:39:08 -0300 Subject: [PATCH 5/8] travis after_failure script --- .travis.yml | 6 ++++++ tests/scripts/travis_after_failure.sh | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/scripts/travis_after_failure.sh diff --git a/.travis.yml b/.travis.yml index 660fb448..2653fc16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,10 @@ env: - FEDORA_VERSION="3.5" - FEDORA_VERSION="3.6.2" - FEDORA_VERSION="3.7.0" + global: + # This key is unique to the Islandora/islandora repository; logging will + # fail on forked repositories unless a new unique key is generated for them. + - secure: "nTv2Zb/qKlECK+xE5ahbfXI9ZZbf2ZMd796q7oPlTxUwvu6nomHnUOjJATl6tq2cj23PyJ89Jlgl5cMZ5h0QMUzYpN5hPyY6oCJxWgFamFaE3bv5E/rBd1f6WVTJW7S4UKn8Mr9R2PrX+ZxQZGVIigAfR8VfhQuP8PcuO5eMLBk=" before_install: - export ISLANDORA_DIR=$TRAVIS_BUILD_DIR - $TRAVIS_BUILD_DIR/tests/scripts/travis_setup.sh @@ -19,3 +23,5 @@ script: - drush coder-review --reviews=production,security,style,i18n,potx,sniffer islandora - phpcpd --names *.module,*.inc,*.test sites/all/modules/islandora - drush test-run --uri=http://localhost:8081 Islandora +after_failure: + - $TRAVIS_BUILD_DIR/tests/scripts/travis_after_install.sh diff --git a/tests/scripts/travis_after_failure.sh b/tests/scripts/travis_after_failure.sh new file mode 100644 index 00000000..288cb75c --- /dev/null +++ b/tests/scripts/travis_after_failure.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Get the end portion of the TRAVIS_REPO_SLUG for the branch name. +DELIMITED_SLUG = $(echo $TRAVIS_REPO_SLUG | tr "/" "\n") +CURRENT_REPO = "${DELIMITED_SLUG[1]}" + +# Git business +export VERBOSE_DIR = $HOME/sites/default/files/simpletest/verbose +cd $HOME +git clone https://islandora-logger:$LOGGER_PW@github.com/Islandora/islandora_travis_logs.git +cd islandora_travis_logs +git checkout -B $CURRENT_REPO + +# Out with the old, in with the new +git rm $HOME/islandora_travis_logs/*.* +cp $VERBOSE_DIR/*.* $HOME/islandora_travis_logs +git add -A +git commit -m "Job: $TRAVIS_JOB_NUMBER Commit: $TRAVIS_COMMIT" +git push origin $CURRENT_REPO From 0f551f87dae0f789117a0ac84f060d34793d3de5 Mon Sep 17 00:00:00 2001 From: qadan Date: Wed, 23 Apr 2014 11:35:30 -0300 Subject: [PATCH 6/8] yml whoops --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2653fc16..94c3dfbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ branches: only: - /^7.x/ env: + matrix: - FEDORA_VERSION="3.5" - FEDORA_VERSION="3.6.2" - FEDORA_VERSION="3.7.0" From a60a35e316e889261a81e98f0f1bd63cdf4a3943 Mon Sep 17 00:00:00 2001 From: qadan Date: Wed, 23 Apr 2014 11:44:30 -0300 Subject: [PATCH 7/8] fixes to placate adam --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 94c3dfbf..0684252a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ branches: - /^7.x/ env: matrix: - - FEDORA_VERSION="3.5" - - FEDORA_VERSION="3.6.2" - - FEDORA_VERSION="3.7.0" + - FEDORA_VERSION="3.5" + - FEDORA_VERSION="3.6.2" + - FEDORA_VERSION="3.7.0" global: # This key is unique to the Islandora/islandora repository; logging will # fail on forked repositories unless a new unique key is generated for them. @@ -25,4 +25,4 @@ script: - phpcpd --names *.module,*.inc,*.test sites/all/modules/islandora - drush test-run --uri=http://localhost:8081 Islandora after_failure: - - $TRAVIS_BUILD_DIR/tests/scripts/travis_after_install.sh + - $ISLANDORA_DIR/tests/scripts/travis_after_install.sh From 2267c4b566ca01bbb3e13fe85000da65d38942fe Mon Sep 17 00:00:00 2001 From: qadan Date: Wed, 23 Apr 2014 12:04:20 -0300 Subject: [PATCH 8/8] i am not a clever man --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0684252a..84b226d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,4 @@ script: - phpcpd --names *.module,*.inc,*.test sites/all/modules/islandora - drush test-run --uri=http://localhost:8081 Islandora after_failure: - - $ISLANDORA_DIR/tests/scripts/travis_after_install.sh + - $ISLANDORA_DIR/tests/scripts/travis_after_failure.sh