271fdc1ca86658da2928dd083c8105d35cc6e8d4
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 namespace Civi\Angular
;
30 require_once 'CiviTest/CiviUnitTestCase.php';
33 * Test the Angular base page.
35 class ManagerTest
extends \CiviUnitTestCase
{
43 * @var \CRM_Core_Resources
50 protected function setUp() {
51 $this->useTransaction(TRUE);
53 $this->createLoggedInUser();
54 $this->res
= \CRM_Core_Resources
::singleton();
55 $this->angular
= new Manager($this->res
);
59 * Modules appear to be well-defined.
61 public function testGetModules() {
62 $modules = $this->angular
->getModules();
71 foreach ($modules as $module) {
72 $this->assertTrue(is_array($module));
73 $this->assertTrue(is_string($module['ext']));
74 if (isset($module['js'])) {
75 $this->assertTrue(is_array($module['js']));
76 foreach ($module['js'] as $file) {
77 $this->assertTrue(file_exists($this->res
->getPath($module['ext'], $file)));
81 if (isset($module['css'])) {
82 $this->assertTrue(is_array($module['css']));
83 foreach ($module['css'] as $file) {
84 $this->assertTrue(file_exists($this->res
->getPath($module['ext'], $file)));
88 if (isset($module['partials'])) {
89 $this->assertTrue(is_array($module['partials']));
90 foreach ((array) $module['partials'] as $basedir) {
91 $this->assertTrue(is_dir($this->res
->getPath($module['ext']) . '/' . $basedir));
92 $counts['partials']++
;
95 if (isset($module['settings'])) {
96 $this->assertTrue(is_array($module['settings']));
97 foreach ($module['settings'] as $name => $value) {
98 $counts['settings']++
;
103 $this->assertTrue($counts['js'] > 0, 'Expect to find at least one JS file');
104 $this->assertTrue($counts['css'] > 0, 'Expect to find at least one CSS file');
105 $this->assertTrue($counts['partials'] > 0, 'Expect to find at least one partial HTML file');
106 $this->assertTrue($counts['settings'] > 1, 'Expect to find at least one setting');
110 * Get HTML fragments from an example module.
112 public function testGetPartials() {
113 $partials = $this->angular
->getPartials('crmMailing');
114 $this->assertRegExp('/\<form.*name="crmMailing"/', $partials['~/crmMailing/EditMailingCtrl/2step.html']);
115 // If crmMailing changes, feel free to use a different example.
119 * Get a translatable string from an example module.
121 public function testGetStrings() {
122 $strings = $this->angular
->getStrings('crmMailing');
123 $this->assertTrue(in_array('Save Draft', $strings));
124 // If crmMailing changes, feel free to use a different example.