From fdabc6d75d0f6ceedbddca7d59b3865f3f4c10b6 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Dec 2019 19:03:53 -0800 Subject: [PATCH] afform_mock - The extra dep should be a real module Using a real Angular module means that the page can be opened in an E2E test. --- ext/afform/mock/ang/mockBespoke.ang.php | 29 +++++++++++++++++++ ext/afform/mock/ang/mockBespoke.css | 1 + ext/afform/mock/ang/mockBespoke.js | 4 +++ ext/afform/mock/ang/mockPage.aff.json | 2 +- .../mock/tests/phpunit/api/v4/AfformTest.php | 10 +++---- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 ext/afform/mock/ang/mockBespoke.ang.php create mode 100644 ext/afform/mock/ang/mockBespoke.css create mode 100644 ext/afform/mock/ang/mockBespoke.js diff --git a/ext/afform/mock/ang/mockBespoke.ang.php b/ext/afform/mock/ang/mockBespoke.ang.php new file mode 100644 index 0000000000..ecbfb40aa9 --- /dev/null +++ b/ext/afform/mock/ang/mockBespoke.ang.php @@ -0,0 +1,29 @@ + + array ( + 0 => 'ang/mockBespoke.js', + 1 => 'ang/mockBespoke/*.js', + 2 => 'ang/mockBespoke/*/*.js', + ), + 'css' => + array ( + 0 => 'ang/mockBespoke.css', + ), + 'partials' => + array ( + 0 => 'ang/mockBespoke', + ), + 'requires' => + array ( + 0 => 'crmUi', + 1 => 'crmUtil', + 2 => 'ngRoute', + ), + 'settings' => + array ( + ), +); diff --git a/ext/afform/mock/ang/mockBespoke.css b/ext/afform/mock/ang/mockBespoke.css new file mode 100644 index 0000000000..3e347a3533 --- /dev/null +++ b/ext/afform/mock/ang/mockBespoke.css @@ -0,0 +1 @@ +/* Add any CSS rules for Angular module "mockBespoke" */ diff --git a/ext/afform/mock/ang/mockBespoke.js b/ext/afform/mock/ang/mockBespoke.js new file mode 100644 index 0000000000..9eaf76640f --- /dev/null +++ b/ext/afform/mock/ang/mockBespoke.js @@ -0,0 +1,4 @@ +(function(angular, $, _) { + // Declare a list of dependencies. + angular.module('mockBespoke', CRM.angRequires('mockBespoke')); +})(angular, CRM.$, CRM._); diff --git a/ext/afform/mock/ang/mockPage.aff.json b/ext/afform/mock/ang/mockPage.aff.json index de1f8212ec..2bdf31cc78 100644 --- a/ext/afform/mock/ang/mockPage.aff.json +++ b/ext/afform/mock/ang/mockPage.aff.json @@ -1 +1 @@ -{"server_route": "civicrm/mock-page", "requires":["extraMock"], "permission": "access Foobar" } +{"server_route": "civicrm/mock-page", "requires":["mockBespoke"], "permission": "access Foobar" } diff --git a/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php b/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php index cd1af772d2..392e9f9501 100644 --- a/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php +++ b/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php @@ -205,9 +205,9 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { // The default mockPage has 1 explicit requirement + 2 automatic requirements. Civi\Api4\Afform::revert()->addWhere('name', '=', $formName)->execute(); $angModule = Civi::service('angular')->getModule($formName); - $this->assertEquals(['afCore', 'extraMock', 'mockBareFile', 'mockFoo'], $angModule['requires']); + $this->assertEquals(['afCore', 'mockBespoke', 'mockBareFile', 'mockFoo'], $angModule['requires']); $storedRequires = Civi\Api4\Afform::get()->addWhere('name', '=', $formName)->addSelect('requires')->execute(); - $this->assertEquals(['extraMock'], $storedRequires[0]['requires']); + $this->assertEquals(['mockBespoke'], $storedRequires[0]['requires']); // Knock down to 1 explicit + 1 automatic. Civi\Api4\Afform::update() @@ -216,9 +216,9 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { ->setValues(['layout' => '
The bare file says ""
']) ->execute(); $angModule = Civi::service('angular')->getModule($formName); - $this->assertEquals(['afCore', 'extraMock', 'mockBareFile'], $angModule['requires']); + $this->assertEquals(['afCore', 'mockBespoke', 'mockBareFile'], $angModule['requires']); $storedRequires = Civi\Api4\Afform::get()->addWhere('name', '=', $formName)->addSelect('requires')->execute(); - $this->assertEquals(['extraMock'], $storedRequires[0]['requires']); + $this->assertEquals(['mockBespoke'], $storedRequires[0]['requires']); // Remove the last explict and implicit requirements. Civi\Api4\Afform::update() @@ -236,7 +236,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { Civi\Api4\Afform::revert()->addWhere('name', '=', $formName)->execute(); $angModule = Civi::service('angular')->getModule($formName); - $this->assertEquals(['afCore', 'extraMock', 'mockBareFile', 'mockFoo'], $angModule['requires']); + $this->assertEquals(['afCore', 'mockBespoke', 'mockBareFile', 'mockFoo'], $angModule['requires']); } } -- 2.25.1