CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • Are they helpers to test smarty templates?
Pages: [1]

Author Topic: Are they helpers to test smarty templates?  (Read 2218 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Are they helpers to test smarty templates?
September 13, 2011, 11:26:55 pm
Hi,

Think we should test/document the smarty {crmAPI}, so take some template containing various {crmAPI} calls, and check if the result is there.

Are they already helpers or examples of testing smarty templates?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Are they helpers to test smarty templates?
September 14, 2011, 06:28:10 pm
When working on the patch/test for CRM_Core_Region, it was handy to use some inline Smarty code, e.g.

Code: [Select]
    function setUp( )
    {
        parent::setUp();
        require_once 'CRM/Core/Smarty.php';
        require_once 'CRM/Core/Smarty/resources/String.php';
        civicrm_smarty_register_string_resource( );
    }

    function testDefault() {
        $smarty = CRM_Core_Smarty::singleton();
        $actual = $smarty->fetch('string:{crmRegion name=testDefault}default<br/>{/crmRegion}');
        $expected = 'default<br/>';
        $this->assertEquals($expected, $actual);
    }

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • Are they helpers to test smarty templates?

This forum was archived on 2017-11-26.