Bläddra i källkod

Removed config for menu items; made all menu items suggestions.

Lacey Sanderson 5 år sedan
förälder
incheckning
ff30d619b5

+ 22 - 21
composer.lock

@@ -115,27 +115,28 @@
         },
         {
             "name": "guzzlehttp/guzzle",
-            "version": "6.3.3",
+            "version": "6.4.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/guzzle/guzzle.git",
-                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
+                "reference": "0895c932405407fd3a7368b6910c09a24d26db11"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
-                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
+                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
+                "reference": "0895c932405407fd3a7368b6910c09a24d26db11",
                 "shasum": ""
             },
             "require": {
+                "ext-json": "*",
                 "guzzlehttp/promises": "^1.0",
-                "guzzlehttp/psr7": "^1.4",
+                "guzzlehttp/psr7": "^1.6.1",
                 "php": ">=5.5"
             },
             "require-dev": {
                 "ext-curl": "*",
                 "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
-                "psr/log": "^1.0"
+                "psr/log": "^1.1"
             },
             "suggest": {
                 "psr/log": "Required for using the Log middleware"
@@ -147,12 +148,12 @@
                 }
             },
             "autoload": {
-                "files": [
-                    "src/functions_include.php"
-                ],
                 "psr-4": {
                     "GuzzleHttp\\": "src/"
-                }
+                },
+                "files": [
+                    "src/functions_include.php"
+                ]
             },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
@@ -176,7 +177,7 @@
                 "rest",
                 "web service"
             ],
-            "time": "2018-04-22T15:46:56+00:00"
+            "time": "2019-10-23T15:58:00+00:00"
         },
         {
             "name": "guzzlehttp/promises",
@@ -1754,16 +1755,16 @@
         },
         {
             "name": "symfony/console",
-            "version": "v4.3.4",
+            "version": "v4.3.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/console.git",
-                "reference": "de63799239b3881b8a08f8481b22348f77ed7b36"
+                "reference": "929ddf360d401b958f611d44e726094ab46a7369"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/console/zipball/de63799239b3881b8a08f8481b22348f77ed7b36",
-                "reference": "de63799239b3881b8a08f8481b22348f77ed7b36",
+                "url": "https://api.github.com/repos/symfony/console/zipball/929ddf360d401b958f611d44e726094ab46a7369",
+                "reference": "929ddf360d401b958f611d44e726094ab46a7369",
                 "shasum": ""
             },
             "require": {
@@ -1825,7 +1826,7 @@
             ],
             "description": "Symfony Console Component",
             "homepage": "https://symfony.com",
-            "time": "2019-08-26T08:26:39+00:00"
+            "time": "2019-10-07T12:36:49+00:00"
         },
         {
             "name": "symfony/polyfill-ctype",
@@ -2004,16 +2005,16 @@
         },
         {
             "name": "symfony/service-contracts",
-            "version": "v1.1.6",
+            "version": "v1.1.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/service-contracts.git",
-                "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3"
+                "reference": "ffcde9615dc5bb4825b9f6aed07716f1f57faae0"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ea7263d6b6d5f798b56a45a5b8d686725f2719a3",
-                "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3",
+                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffcde9615dc5bb4825b9f6aed07716f1f57faae0",
+                "reference": "ffcde9615dc5bb4825b9f6aed07716f1f57faae0",
                 "shasum": ""
             },
             "require": {
@@ -2058,7 +2059,7 @@
                 "interoperability",
                 "standards"
             ],
-            "time": "2019-08-20T14:44:19+00:00"
+            "time": "2019-09-17T11:12:18+00:00"
         },
         {
             "name": "theseer/tokenizer",

+ 0 - 132
tests/tripal_jbrowse/jbrowseInstanceNodeTest.php

@@ -1,132 +0,0 @@
-<?php
-namespace Tests\tripal_jbrowse;
-
-use StatonLab\TripalTestSuite\DBTransaction;
-use StatonLab\TripalTestSuite\TripalTestCase;
-use Faker\Factory;
-
-/**
- * Tests the JBrowse Instance Node Type.
- */
-class jbrowseInstanceNodeTest extends TripalTestCase {
-  // Uncomment to auto start and rollback db transactions per test method.
-  use DBTransaction;
-
-  /**
-   * JBrowse Instance Node Type exists.
-   *
-   * Check that the JBrowse Instance node type exists. It should be created
-   * when the module is installed by the Drupal Node API.
-   */
-  public function testJbrowseInstanceNodeTypeExists() {
-
-    // Get a list of all types available.
-    $types = node_type_get_types();
-
-    // The JBrowse Instance node type must be in the list.
-    $this->assertArrayHasKey('jbrowse_instance', $types, '"JBrowse Instance" node type is not registered with Drupal.');
-
-    // Check that the expected fields exist and are attached to the JBrowse instance node type.
-    // First retrieve all fields for this node type.
-    $fields = field_info_instances('node', 'jbrowse_instance');
-    // Now check that those important to us, exist.
-    $this->assertArrayHasKey('field_jburl', $fields,
-      'The "Existing JBrowse URL" field is not attached to the JBrowse Instance node type.');
-    $this->assertArrayHasKey('field_datadir', $fields,
-      'The "Data Directory" field is not attached to the JBrowse Instance node type.');
-    $this->assertArrayHasKey('field_jbloc', $fields,
-      'The "Start Location" field is not attached to the JBrowse Instance node type.');
-    $this->assertArrayHasKey('field_jbtracks', $fields,
-      'The "Tracks to Display" field is not attached to the JBrowse Instance node type.');
-  }
-
-  /**
-   * Test Creating a JBrowse Instance Node.
-   *
-   * Note: We can't test this by submitting the form via PUT because it requires
-   *  permission to access /node/add/jbrowse_instance; however, we don't yet have a
-   *  way to do this with TripalTestSuite. Furthermore, testing HTTP Requests
-   *  would not give us access to the data added via the test due to database
-   *  transactions.
-   */
-  public function testJBrowseInstanceNodeCreate() {
-    module_load_include('inc', 'node', 'node.pages');
-
-    // Log in the god user.
-    global $user;
-    $user = user_load(1);
-    $node = array('type' => 'jbrowse_instance');
-
-    // Fill in the form.
-    $faker = Factory::create();
-    $form_state = array('values' => array());
-    $form_state['values']['title'] = $faker->words(3, true);
-    $form_state['values']['field_jburl']['und'][0]['url'] = 'https://jbrowse.org/code/JBrowse-1.15.4/';
-    $form_state['values']['field_datadir']['und'][0] = 'sample_data/json/volvox';
-    $form_state['values']['field_jbloc']['und'][0] = 'ctgA:1..11000';
-    $form_state['values']['field_jbtracks']['und'][0] = 'DNA,Genes,volvox-sorted-vcf,volvox_microarray_bw_density,volvox_bb';
-    $form_state['values']['op'] = t('Save');
-
-    // Execute the node creation form.
-    drupal_form_submit('jbrowse_instance_node_form', $form_state, (object) $node);
-
-    // Retrieve any errors.
-    $errors = form_get_errors();
-
-    // Assert that there must not be any.
-    $this->assertEmpty($errors, 'Form submission returned the following errors:'.print_r($errors,TRUE));
-
-    // Check that there is a test jbrowse instance.
-    $result = db_query('SELECT * FROM {node} WHERE title=:name',
-      array(':name' => $form_state['values']['title']));
-    $this->assertEquals(1, $result->rowCount(), 'Unable to select the JBrowse Instance using the name.');
-
-    // log out the god user.
-    $user = drupal_anonymous_user();
-  }
-
-  /**
-   * Update an existing Blast Database Node.
-   */
-  public function testJBrowseInstanceNodeUpdate() {
-    module_load_include('inc', 'node', 'node.pages');
-
-    // Log in the god user.
-    global $user;
-    $user = user_load(1);
-
-    // Create the node in the first place.
-    $seeder = \Tests\DatabaseSeeders\JBrowseInstanceNodeSeeder::seed();
-    $node = $seeder->getNode();
-
-    // Now use the form to edit it :-)
-    // Specifically, we will change the name, url and data directory.
-    $faker = Factory::create();
-    $form_state = array('values' => array());
-    $form_state['values']['title'] = $faker->words(5, true);
-    $form_state['values']['field_jburl']['und'][0]['url'] = 'https://jbrowse.org/code/JBrowse-1.15.4/';
-    $form_state['values']['field_datadir']['und'][0] = 'sample_data/json/modencode';
-    $form_state['values']['op'] = t('Save');
-
-    // Execute the node creation form.
-    drupal_form_submit('jbrowse_instance_node_form', $form_state, $node);
-
-    // Retrieve any errors.
-    $errors = form_get_errors();
-    // Assert that there must not be any.
-    $this->assertEmpty($errors, 'Form submission returned the following errors:'.print_r($errors,TRUE));
-
-    // Check that there is a test jbrowse instance.
-    $result = db_query('SELECT * FROM {node} WHERE title=:name',
-      array(':name' => $form_state['values']['title']));
-    $this->assertEquals(1, $result->rowCount(), 'Unable to select the JBrowse Instance using the name.');
-
-    // log out the god user.
-    $user = drupal_anonymous_user();
-  }
-
-  /**
-   * Test deleting a node.
-   * NOTE: We cannot test this via drupal_form_submit() since it requires a confirmation.
-   */
-}

+ 33 - 0
tests/tripal_jbrowse_page/dotModuleTest.php

@@ -0,0 +1,33 @@
+<?php
+namespace Tests\tripal_jbrowse_page;
+
+use StatonLab\TripalTestSuite\DBTransaction;
+use StatonLab\TripalTestSuite\TripalTestCase;
+
+class dotModuleTest extends TripalTestCase {
+  // Uncomment to auto start and rollback db transactions per test method.
+  use DBTransaction;
+
+  /**
+   * Tests tripal_jbrowse_page_menu().
+   */
+  public function testHookMenu() {
+
+    $menu_items = tripal_jbrowse_page_menu();
+    foreach ($menu_items as $path => $item) {
+
+      // First ensure there are all the menu item keys required.
+      $this->assertArrayHasKey('title', $item);
+      $this->assertArrayHasKey('description', $item);
+      $this->assertArrayHasKey('page callback', $item);
+      $this->assertArrayHasKey('type', $item);
+      $this->assertArrayHasKey('access arguments', $item);
+
+      // Check that all jbrowse instance paths are the correct type.
+      $path_parts = explode('/', $path);
+      if (($path_parts[0] == 'jbrowse') && (sizeof($path_parts) > 1)) {
+        $this->assertEquals(MENU_SUGGESTED_ITEM, $item['type']);
+      }
+    }
+  }
+}

+ 0 - 13
tripal_jbrowse_page/includes/tripal_jbrowse_page.admin.inc

@@ -14,15 +14,6 @@ function tripal_jbrowse_page_settings_form($form, $form_state) {
     '#title' => 'General Page Integration Settings'
   ];
 
-  $form['general']['create_menu_items'] = [
-    '#type' => 'checkbox',
-    '#title' => 'Create Menu Items',
-    '#description' => 'Checking this box ensures that menu items under
-      "Navigation" will be created for each JBrowse instance. This only
-      applies to JBrowse Instances with a page.',
-    '#default_value' => variable_get('trpjbrowse_page_create_menu_items', 1),
-  ];
-
   $form['general']['embed'] = [
     '#type' => 'checkbox',
     '#title' => 'Embed JBrowse in your Tripal Site',
@@ -78,10 +69,6 @@ function tripal_jbrowse_page_settings_form_submit($form, $form_state) {
   $values = $form_state['values'];
 
   // General Settings.
-  variable_set(
-    'trpjbrowse_page_create_menu_items',
-    $values['create_menu_items']
-  );
   variable_set(
     'trpjbrowse_page_embed',
     $values['embed']

+ 1 - 7
tripal_jbrowse_page/tripal_jbrowse_page.module

@@ -25,12 +25,6 @@ function tripal_jbrowse_page_menu() {
 
     if (tripal_jbrowse_page_is_instance_public($instance->id)) {
 
-      // The type of menu needs to be determined.
-      $create_links = variable_get('trpjbrowse_page_create_menu_items', 1);
-      $menu_type = MENU_CALLBACK;
-      if ($create_links) {
-        $menu_type = MENU_NORMAL_ITEM;
-      }
       // Create the menu item.
       $path = 'jbrowse/'.$instance->organism->genus . '-' . $instance->organism->species;
       $items[$path] = [
@@ -40,7 +34,7 @@ function tripal_jbrowse_page_menu() {
         'page arguments' => [1],
         'access arguments' => ['access content'],
         'file' => 'includes/tripal_jbrowse_page.page.inc',
-        'type' => $menu_type,
+        'type' => MENU_SUGGESTED_ITEM,
       ];
     }
   }