Commit 9d7ff5b1 authored by totten's avatar totten
Browse files

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.
parent e4322bb4
<?php
// This file declares an Angular module which can be autoloaded
// in CiviCRM. See also:
// \https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules/n
return array (
'js' =>
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 (
),
);
/* Add any CSS rules for Angular module "mockBespoke" */
(function(angular, $, _) {
// Declare a list of dependencies.
angular.module('mockBespoke', CRM.angRequires('mockBespoke'));
})(angular, CRM.$, CRM._);
{"server_route": "civicrm/mock-page", "requires":["extraMock"], "permission": "access Foobar" }
{"server_route": "civicrm/mock-page", "requires":["mockBespoke"], "permission": "access Foobar" }
......@@ -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' => '<div>The bare file says "<span mock-bare-file/>"</div>'])
->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']);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment