3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
12 namespace Civi\Angular
;
15 * Ensure that all Angular *.html partials are well-formed.
17 class PartialSyntaxTest
extends \CiviUnitTestCase
{
25 * @var \CRM_Core_Resources
32 protected function setUp() {
33 $this->useTransaction(TRUE);
35 $this->createLoggedInUser();
36 $this->res
= \CRM_Core_Resources
::singleton();
37 $this->angular
= new Manager($this->res
);
40 public function basicConsistencyExamples() {
44 '<div foo="bar"></div>',
45 '<div foo="bar"></div>',
49 '<div foo="bar"></div>',
52 '<div foo=\'bar\'></div>',
53 '<div foo="bar"></div>',
56 '<div foo=\'ts("Hello world")\'></div>',
57 '<div foo=\'ts("Hello world")\'></div>',
60 '<div foo="ts(\'Hello world\')\"></div>',
61 '<div foo="ts(\'Hello world\')\"></div>',
64 '<a href="{{foo}}" title="{{bar}}"></a>',
65 '<a href="{{foo}}" title="{{bar}}"></a>',
68 '<div ng-if="a && b"></div>',
69 '<div ng-if="a && b"></div>',
76 * @param string $inputHtml
77 * @param string $expectHtml
78 * @dataProvider basicConsistencyExamples
80 public function testConsistencyExamples($inputHtml, $expectHtml) {
82 $this->assertEquals($expectHtml, $coder->recode($inputHtml));
87 public function testAllPartials() {
88 $coder = new \Civi\Angular\
Coder();
91 foreach ($this->angular
->getModules() as $module => $moduleDefn) {
92 $partials = $this->angular
->getPartials($module);
93 foreach ($partials as $path => $html) {
95 if (!$coder->checkConsistentHtml($html)) {
96 $recodedHtml = $coder->recode($html);
97 $this->assertEquals($html, $recodedHtml, "File $path has inconsistent HTML. Use tools/scripts/check-angular.php to debug. ");
102 $this->assertTrue($count > 0);