(REF) Convert YAML fixtures to JSON fixtures. Reset symfony/yaml dependency.
authorTim Otten <totten@civicrm.org>
Fri, 14 Jun 2019 02:48:01 +0000 (22:48 -0400)
committerTim Otten <totten@civicrm.org>
Fri, 14 Jun 2019 02:48:01 +0000 (22:48 -0400)
Overview
--------

The test suite includes some tests that read fixture data files (i.e. YAML files). This patch
provides a safer way to address a dependency-management issue with parsing YAML files.

Before
------

* In the last public release (`5.14`), the `symfony/yaml` package was not included with `civicrm-core`.
  However, it was loaded during testing by virtue of running `phpunit6`.
* In the `5.15` RC code, `symfony/yaml` was added -- so that the test suite worked in `phpunit6`.
  However, this also added `symfony/yaml` to the general runtime distribution - which is liable to create conflicts
  with Civi extensions and CMS modules that also bundle `symfony/yaml`. (It's a popular package.)

After
-----

* The test suite no longer uses YAML, and the build no longer requires `symfony/yaml`. Instead, it uses JSON.

13 files changed:
composer.json
composer.lock
tests/fixtures/case.json [new file with mode: 0644]
tests/fixtures/case.yaml [deleted file]
tests/fixtures/case_contact.json [new file with mode: 0644]
tests/fixtures/case_contact.yaml [deleted file]
tests/fixtures/case_relationships.json [new file with mode: 0644]
tests/fixtures/case_relationships.yaml [deleted file]
tests/fixtures/case_types.json [new file with mode: 0644]
tests/fixtures/case_types.yaml [deleted file]
tests/fixtures/contacts.json [new file with mode: 0644]
tests/fixtures/contacts.yaml [deleted file]
tests/phpunit/CiviTest/CiviUnitTestCase.php

index 050b5362f20977de45e1e76841451e819683de17..271f33cf59a0bc2c9dd87c7af35b463709869405 100644 (file)
@@ -42,7 +42,6 @@
     "symfony/event-dispatcher": "^2.8.44 || ~3.0",
     "symfony/filesystem": "^2.8.44 || ~3.0",
     "symfony/process": "^2.8.44 || ~3.0",
-    "symfony/yaml": "^2.8.44 || ~3.0",
     "psr/log": "~1.1",
     "symfony/finder": "^2.8.44 || ~3.0",
     "tecnickcom/tcpdf" : "6.2.*",
index d4976108dc8cfcf1eb202a3c5e20123d02094c84..7fe362a0ac3f8d57c747351dcb97678c96e59718 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "ef15b267ffebe1be949611b7c8618924",
+    "content-hash": "a337d7adf0d57f28a1aff44917fe1b92",
     "packages": [
         {
             "name": "civicrm/civicrm-cxn-rpc",
         },
         {
             "name": "symfony/polyfill-ctype",
-            "version": "v1.8.0",
+            "version": "v1.11.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-ctype.git",
-                "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
+                "reference": "82ebae02209c21113908c229e9883c419720738a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
-                "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
+                "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
+                "reference": "82ebae02209c21113908c229e9883c419720738a",
                 "shasum": ""
             },
             "require": {
                 "php": ">=5.3.3"
             },
+            "suggest": {
+                "ext-ctype": "For best performance"
+            },
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.8-dev"
+                    "dev-master": "1.11-dev"
                 }
             },
             "autoload": {
                 "polyfill",
                 "portable"
             ],
-            "time": "2018-04-30T19:57:29+00:00"
+            "time": "2019-02-06T07:57:58+00:00"
         },
         {
             "name": "symfony/polyfill-iconv",
             "homepage": "https://symfony.com",
             "time": "2018-07-26T11:13:39+00:00"
         },
-        {
-            "name": "symfony/yaml",
-            "version": "v2.8.44",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/yaml.git",
-                "reference": "fbf876678e29dc634430dcf0096e216eb0004467"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/yaml/zipball/fbf876678e29dc634430dcf0096e216eb0004467",
-                "reference": "fbf876678e29dc634430dcf0096e216eb0004467",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.9",
-                "symfony/polyfill-ctype": "~1.8"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.8-dev"
-                }
-            },
-            "autoload": {
-                "psr-4": {
-                    "Symfony\\Component\\Yaml\\": ""
-                },
-                "exclude-from-classmap": [
-                    "/Tests/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                },
-                {
-                    "name": "Symfony Community",
-                    "homepage": "https://symfony.com/contributors"
-                }
-            ],
-            "description": "Symfony Yaml Component",
-            "homepage": "https://symfony.com",
-            "time": "2018-07-26T09:03:18+00:00"
-        },
         {
             "name": "tecnickcom/tcpdf",
             "version": "6.2.26",
diff --git a/tests/fixtures/case.json b/tests/fixtures/case.json
new file mode 100644 (file)
index 0000000..493ca8d
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "civicrm_case": [
+        {
+            "id": 1,
+            "case_type_id": 1,
+            "status_id": 1
+        }
+    ]
+}
\ No newline at end of file
diff --git a/tests/fixtures/case.yaml b/tests/fixtures/case.yaml
deleted file mode 100644 (file)
index 25e7947..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-civicrm_case:
-  -
-    id: 1
-    case_type_id: 1
-    status_id: 1
diff --git a/tests/fixtures/case_contact.json b/tests/fixtures/case_contact.json
new file mode 100644 (file)
index 0000000..b589251
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "civicrm_case_contact": [
+        {
+            "case_id": 1,
+            "contact_id": 3
+        }
+    ]
+}
\ No newline at end of file
diff --git a/tests/fixtures/case_contact.yaml b/tests/fixtures/case_contact.yaml
deleted file mode 100644 (file)
index 17d8b90..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-civicrm_case_contact:
-  -
-    case_id: 1
-    contact_id: 3
diff --git a/tests/fixtures/case_relationships.json b/tests/fixtures/case_relationships.json
new file mode 100644 (file)
index 0000000..f1c0dc9
--- /dev/null
@@ -0,0 +1,48 @@
+{
+    "civicrm_relationship_type": [
+        {
+            "name_a_b": "Homeless Services Coordinator is",
+            "label_a_b": "Homeless Services Coordinator is",
+            "name_b_a": "Homeless Services Coordinator",
+            "label_b_a": "Homeless Services Coordinator",
+            "description": "Homeless Services Coordinator",
+            "contact_type_a": "Individual",
+            "contact_type_b": "Individual",
+            "is_reserved": 0,
+            "is_active": 1
+        },
+        {
+            "name_a_b": "Health Services Coordinator is",
+            "label_a_b": "Health Services Coordinator is",
+            "name_b_a": "Health Services Coordinator",
+            "label_b_a": "Health Services Coordinator",
+            "description": "Health Services Coordinator",
+            "contact_type_a": "Individual",
+            "contact_type_b": "Individual",
+            "is_reserved": 0,
+            "is_active": 1
+        },
+        {
+            "name_a_b": "Senior Services Coordinator is",
+            "label_a_b": "Senior Services Coordinator is",
+            "name_b_a": "Senior Services Coordinator",
+            "label_b_a": "Senior Services Coordinator",
+            "description": "Senior Services Coordinator",
+            "contact_type_a": "Individual",
+            "contact_type_b": "Individual",
+            "is_reserved": 0,
+            "is_active": 1
+        },
+        {
+            "name_a_b": "Benefits Specialist is",
+            "label_a_b": "Benefits Specialist is",
+            "name_b_a": "Benefits Specialist",
+            "label_b_a": "Benefits Specialist",
+            "description": "Benefits Specialist",
+            "contact_type_a": "Individual",
+            "contact_type_b": "Individual",
+            "is_reserved": 0,
+            "is_active": 1
+        }
+    ]
+}
\ No newline at end of file
diff --git a/tests/fixtures/case_relationships.yaml b/tests/fixtures/case_relationships.yaml
deleted file mode 100644 (file)
index 96323d0..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-civicrm_relationship_type:
-  -
-    name_a_b: Homeless Services Coordinator is
-    label_a_b: Homeless Services Coordinator is
-    name_b_a: Homeless Services Coordinator
-    label_b_a: Homeless Services Coordinator
-    description: Homeless Services Coordinator
-    contact_type_a: Individual
-    contact_type_b: Individual
-    is_reserved: 0
-    is_active: 1
-
-  -
-    name_a_b: Health Services Coordinator is
-    label_a_b: Health Services Coordinator is
-    name_b_a: Health Services Coordinator
-    label_b_a: Health Services Coordinator
-    description: Health Services Coordinator
-    contact_type_a: Individual
-    contact_type_b: Individual
-    is_reserved: 0
-    is_active: 1
-
-  -
-    name_a_b: Senior Services Coordinator is
-    label_a_b: Senior Services Coordinator is
-    name_b_a: Senior Services Coordinator
-    label_b_a: Senior Services Coordinator
-    description: Senior Services Coordinator
-    contact_type_a: Individual
-    contact_type_b: Individual
-    is_reserved: 0
-    is_active: 1
-
-  -
-    name_a_b: Benefits Specialist is
-    label_a_b: Benefits Specialist is
-    name_b_a: Benefits Specialist
-    label_b_a: Benefits Specialist
-    description: Benefits Specialist
-    contact_type_a: Individual
-    contact_type_b: Individual
-    is_reserved: 0
-    is_active: 1
diff --git a/tests/fixtures/case_types.json b/tests/fixtures/case_types.json
new file mode 100644 (file)
index 0000000..6c2d397
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "civicrm_case_type": [
+        {
+            "id": 1,
+            "name": "housing_support",
+            "title": "Housing Support",
+            "description": "Help homeless individuals obtain temporary and long-term housing",
+            "is_active": 1,
+            "is_reserved": 0,
+            "weight": 1
+        }
+    ]
+}
\ No newline at end of file
diff --git a/tests/fixtures/case_types.yaml b/tests/fixtures/case_types.yaml
deleted file mode 100644 (file)
index 47c47a8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-civicrm_case_type:
-  -
-    id: 1
-    name: housing_support
-    title: Housing Support
-    description: Help homeless individuals obtain temporary and long-term housing
-    is_active: 1
-    is_reserved: 0
-    weight: 1
diff --git a/tests/fixtures/contacts.json b/tests/fixtures/contacts.json
new file mode 100644 (file)
index 0000000..3b5e705
--- /dev/null
@@ -0,0 +1,54 @@
+{
+    "civicrm_contact": [
+        {
+            "id": 3,
+            "contact_type": "Individual",
+            "contact_sub_type": null,
+            "do_not_email": 0,
+            "do_not_phone": 0,
+            "do_not_mail": 0,
+            "do_not_sms": 0,
+            "do_not_trade": 0,
+            "is_opt_out": 0,
+            "legal_identifier": null,
+            "sort_name": "Site Administrator",
+            "display_name": "Site Administrator",
+            "nick_name": null,
+            "legal_name": null,
+            "image_URL": null,
+            "preferred_communication_method": null,
+            "preferred_mail_format": null,
+            "hash": null,
+            "api_key": null,
+            "source": null,
+            "first_name": "Site",
+            "middle_name": null,
+            "last_name": "Administrator"
+        },
+        {
+            "id": 17,
+            "contact_type": "Individual",
+            "contact_sub_type": null,
+            "do_not_email": 0,
+            "do_not_phone": 0,
+            "do_not_mail": 0,
+            "do_not_sms": 0,
+            "do_not_trade": 0,
+            "is_opt_out": 0,
+            "legal_identifier": null,
+            "sort_name": null,
+            "display_name": "Test Contact",
+            "nick_name": null,
+            "legal_name": null,
+            "image_URL": null,
+            "preferred_communication_method": null,
+            "preferred_mail_format": null,
+            "hash": null,
+            "api_key": null,
+            "source": null,
+            "first_name": "Test",
+            "middle_name": null,
+            "last_name": "Contact"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/tests/fixtures/contacts.yaml b/tests/fixtures/contacts.yaml
deleted file mode 100644 (file)
index 42cc887..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-civicrm_contact:
-  -
-    id: 3
-    contact_type: Individual
-    contact_sub_type:
-    do_not_email: 0
-    do_not_phone: 0
-    do_not_mail: 0
-    do_not_sms: 0
-    do_not_trade: 0
-    is_opt_out: 0
-    legal_identifier:
-    sort_name: Site Administrator
-    display_name: Site Administrator
-    nick_name:
-    legal_name:
-    image_URL:
-    preferred_communication_method:
-    preferred_mail_format:
-    hash:
-    api_key:
-    source:
-    first_name: Site
-    middle_name:
-    last_name: Administrator
-
-  -
-    id: 17
-    contact_type: Individual
-    contact_sub_type:
-    do_not_email: 0
-    do_not_phone: 0
-    do_not_mail: 0
-    do_not_sms: 0
-    do_not_trade: 0
-    is_opt_out: 0
-    legal_identifier:
-    sort_name:
-    display_name: Test Contact
-    nick_name:
-    legal_name:
-    image_URL:
-    preferred_communication_method:
-    preferred_mail_format:
-    hash:
-    api_key:
-    source:
-    first_name: Test
-    middle_name:
-    last_name: Contact
index 1c11b5e095ab4eebf54f96c5961ce25585274420..5ecff3a9f59c0933822c6a1f0f3043b69dacc46b 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 use Civi\Payment\System;
-use Symfony\Component\Yaml\Yaml;
 
 /**
  *  Include class definitions
@@ -376,10 +375,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
 
     CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 0;");
 
-    $yamlFiles = glob($fixturesDir . '/*.yaml');
-    foreach ($yamlFiles as $yamlFixture) {
-      $yaml = Yaml::parse(file_get_contents($yamlFixture));
-      foreach ($yaml as $tableName => $vars) {
+    $jsonFiles = glob($fixturesDir . '/*.json');
+    foreach ($jsonFiles as $jsonFixture) {
+      $json = json_decode(file_get_contents($jsonFixture));
+      foreach ($json as $tableName => $vars) {
         if ($tableName === 'civicrm_contact') {
           CRM_Core_DAO::executeQuery('DELETE c FROM civicrm_contact c LEFT JOIN civicrm_domain d ON d.contact_id = c.id WHERE d.id IS NULL');
         }