From a5fec26d4159f0b83f645a32e3d81e87634f1a53 Mon Sep 17 00:00:00 2001
From: Antonio De Marco <antonio@nuvole.org>
Date: Sat, 23 Sep 2017 12:58:53 +0200
Subject: [PATCH] Issue #120: Fix tests.

---
 src/Plugin/PatternBase.php       | 24 +++++++++++++-----------
 tests/src/fixtures/libraries.yml |  2 --
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/Plugin/PatternBase.php b/src/Plugin/PatternBase.php
index c0ad45130..f23567e1c 100644
--- a/src/Plugin/PatternBase.php
+++ b/src/Plugin/PatternBase.php
@@ -104,17 +104,19 @@ abstract class PatternBase extends PluginBase implements PatternInterface, Conta
    *    Item parent set in previous recursive iteration, if any.
    */
   protected function processLibraries(&$libraries, $base_path, $parent = '') {
-    $parents = ['js', 'base', 'layout', 'component', 'state', 'theme'];
-    $_libraries = $libraries;
-    foreach ($_libraries as $name => $values) {
-      $is_asset = in_array($parent, $parents, TRUE);
-      $is_external = isset($values['type']) && $values['type'] == 'external';
-      if ($is_asset && !$is_external) {
-        $libraries[$base_path . DIRECTORY_SEPARATOR . $name] = $values;
-        unset($libraries[$name]);
-      }
-      elseif (!$is_asset && ($parent != 'dependencies')) {
-        $this->processLibraries($libraries[$name], $base_path, $name);
+    if (!is_string($libraries)) {
+      $parents = ['js', 'base', 'layout', 'component', 'state', 'theme'];
+      $_libraries = $libraries;
+      foreach ($_libraries as $name => $values) {
+        $is_asset = in_array($parent, $parents, TRUE);
+        $is_external = isset($values['type']) && $values['type'] == 'external';
+        if ($is_asset && !$is_external) {
+          $libraries[$base_path . DIRECTORY_SEPARATOR . $name] = $values;
+          unset($libraries[$name]);
+        }
+        elseif (!$is_asset) {
+          $this->processLibraries($libraries[$name], $base_path, $name);
+        }
       }
     }
   }
diff --git a/tests/src/fixtures/libraries.yml b/tests/src/fixtures/libraries.yml
index 7c4323089..60870b952 100644
--- a/tests/src/fixtures/libraries.yml
+++ b/tests/src/fixtures/libraries.yml
@@ -73,7 +73,6 @@
         http://example.com/external.min.js: { type: external, minified: true }
         /pattern/base/path/library_two.js: {}
 
-
 -
   actual:
     id: pattern_name
@@ -82,7 +81,6 @@
       - drupal/library_two
   expected: []
 
-
 -
   actual:
     id: pattern_name
-- 
GitLab