From 66d0b6404d8ac63cabb8e4f02b44472c00fdabf2 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 10 Apr 2013 20:50:36 -0300 Subject: [PATCH 1/3] Some modifications, remove duplicate code, run copy paste detector --- .travis.yml | 1 + tests/islandora_test.info | 6 -- tests/islandora_test.module | 152 ------------------------------------ 3 files changed, 1 insertion(+), 158 deletions(-) delete mode 100644 tests/islandora_test.info delete mode 100644 tests/islandora_test.module diff --git a/.travis.yml b/.travis.yml index 0c5fe32a..d95cfb54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,5 @@ before_install: script: - ant -buildfile sites/all/modules/islandora/build.xml lint - drush dcs sites/all/modules/islandora + - phpcpd sites/all/modules/islandora - drush test-run --uri=http://localhost:8081 Islandora diff --git a/tests/islandora_test.info b/tests/islandora_test.info deleted file mode 100644 index c6cb57ad..00000000 --- a/tests/islandora_test.info +++ /dev/null @@ -1,6 +0,0 @@ -name = Islandora Test Module -description = Tests Hooks. Do not enable. -core = 7.x -package = Testing -hidden = TRUE -dependencies[] = islandora diff --git a/tests/islandora_test.module b/tests/islandora_test.module deleted file mode 100644 index 315b88ee..00000000 --- a/tests/islandora_test.module +++ /dev/null @@ -1,152 +0,0 @@ -id == 'test:testIngestedObjectHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_OBJECT_INGESTED_HOOK] = TRUE; - if ($object->label == 'block') { - $context['block'] = TRUE; - } - } - break; - - case 'modify': - if ($object->id == 'test:testModifiedObjectHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_OBJECT_MODIFIED_HOOK] = TRUE; - if (isset($context['params']['label']) && $context['params']['label'] == 'block') { - $context['block'] = TRUE; - } - } - elseif ($object->id == 'test:testPurgedObjectHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_OBJECT_PURGED_HOOK] = TRUE; - if (isset($context['params']['label']) && $context['params']['label'] == 'block') { - $context['block'] = TRUE; - } - elseif (isset($context['params']['label']) && $context['params']['label'] == 'delete') { - $context['delete'] = TRUE; - } - } - break; - - case 'purge': - if ($object->id == 'test:testPurgedObjectHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_OBJECT_PURGED_HOOK] = TRUE; - if ($object->label == 'block') { - $context['block'] = TRUE; - } - elseif ($object->label == 'delete') { - $context['delete'] = TRUE; - } - } - break; - } -} - -/** - * Implements hook_islandora_object_alter(). - */ -function islandora_hooks_test_islandora_datastream_alter(AbstractFedoraObject $object, AbstractFedoraDatastream $datastream, array &$context) { - switch ($context['action']) { - case 'ingest': - if ($object->id == 'test:testIngestedDatastreamHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_DATASTREAM_INGESTED_HOOK] = TRUE; - if ($datastream->label == 'block') { - $context['block'] = TRUE; - } - } - break; - - case 'modify': - if ($object->id == 'test:testModifiedDatastreamHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_DATASTREAM_MODIFIED_HOOK] = TRUE; - if (isset($context['params']['dsLabel']) && $context['params']['dsLabel'] == 'block') { - $context['block'] = TRUE; - } - } - elseif ($object->id == 'test:testPurgedDatastreamHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_DATASTREAM_PURGED_HOOK] = TRUE; - if (isset($context['params']['dsLabel']) && $context['params']['dsLabel'] == 'block') { - $context['block'] = TRUE; - } - elseif (isset($context['params']['dsLabel']) && $context['params']['dsLabel'] == 'delete') { - $context['delete'] = TRUE; - } - } - break; - - case 'purge': - if ($object->id == 'test:testPurgedDatastreamHook') { - $_SESSION['islandora_hooks']['alter'][ISLANDORA_DATASTREAM_PURGED_HOOK] = TRUE; - if ($datastream->label == 'block') { - $context['block'] = TRUE; - } - elseif ($datastream->label == 'delete') { - $context['delete'] = TRUE; - } - } - break; - } -} - -/** - * Implements hook_islandora_object_ingested(). - */ -function islandora_hooks_test_islandora_object_ingested(FedoraObject $object) { - if ($object->id == 'test:testIngestedObjectHook') { - $_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_INGESTED_HOOK] = TRUE; - } -} - -/** - * Implements hook_islandora_object_modified(). - */ -function islandora_hooks_test_islandora_object_modified(FedoraObject $object) { - if ($object->id == 'test:testModifiedObjectHook') { - $_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_MODIFIED_HOOK] = TRUE; - } -} - -/** - * Implements hook_islandora_object_purged(). - */ -function islandora_hooks_test_islandora_object_purged($pid) { - if ($pid == 'test:testPurgedObjectHook') { - $_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_PURGED_HOOK] = TRUE; - } -} - -/** - * Implements hook_islandora_datastream_ingested(). - */ -function islandora_hooks_test_islandora_datastream_ingested(FedoraObject $object, FedoraDatastream $datastream) { - if ($object->id == 'test:testIngestedDatastreamHook' && $datastream->id == "TEST") { - $_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_INGESTED_HOOK] = TRUE; - } -} - -/** - * Implements hook_islandora_datastream_modified(). - */ -function islandora_hooks_test_islandora_datastream_modified(FedoraObject $object, FedoraDatastream $datastream) { - if ($object->id == 'test:testModifiedDatastreamHook' && $datastream->id == "TEST") { - $_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_MODIFIED_HOOK] = TRUE; - } -} - -/** - * Implements hook_islandora_datastream_purged(). - */ -function islandora_hooks_test_islandora_datastream_purged(FedoraObject $object, $dsid) { - if ($object->id == 'test:testPurgedDatastreamHook' && $dsid == "TEST") { - $_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_PURGED_HOOK] = TRUE; - } -} From 3f71651af4cd0395683f679c8950af81da8559b5 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 10 Apr 2013 20:51:03 -0300 Subject: [PATCH 2/3] Add travis_setup --- tests/travis_setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/travis_setup.sh b/tests/travis_setup.sh index abbaccd2..041eb57f 100755 --- a/tests/travis_setup.sh +++ b/tests/travis_setup.sh @@ -12,8 +12,10 @@ export CATALINA_HOME='.' ./bin/startup.sh cd $HOME pyrus channel-discover pear.drush.org +pyrus channel-discover pear.phpqatools.org pyrus install drush/drush pyrus install pear/PHP_CodeSniffer +pyrus install pear.phpunit.de/phpcpd phpenv rehash drush dl --yes drupal cd drupal-* From 010fd655a9edbb1d6090680f072c2807ab911612 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 10 Apr 2013 20:57:44 -0300 Subject: [PATCH 3/3] Added dependancy --- tests/travis_setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/travis_setup.sh b/tests/travis_setup.sh index 041eb57f..b870edb3 100755 --- a/tests/travis_setup.sh +++ b/tests/travis_setup.sh @@ -13,6 +13,7 @@ export CATALINA_HOME='.' cd $HOME pyrus channel-discover pear.drush.org pyrus channel-discover pear.phpqatools.org +pyrus channel-discover pear.netpirates.net pyrus install drush/drush pyrus install pear/PHP_CodeSniffer pyrus install pear.phpunit.de/phpcpd