TS 73 PHP Smarty
PHP Smarty Framework Test Specification for NetBeans 7.3
Author: Vladimir Riha
Version: 1.0
Last Update: 2nd October 2012
Introduction: This specification provides usecases for Smarty support in NetBeans
Mac OS specific details: To find Options on MacOS, go to Netbeans menu -> Preferences
Contents |
Test suite: New template wizard
Purpose: "This test suite checks creating of Smarty template file *tpl"
Setup: "Already created PHP project (without any framework)"
- "New template file wizard"
- "Select File | New File... to open New File dialog
- Select "PHP" in Categories and "Smarty Template" in File Types
- Press Next
- Select some name and specify the path where to save the template
- Press Finish
- EXPECTED RESULT: "New template file is created and opened in editor window."
Test suite: Syntax highlighting
Purpose: "This test suite checks syntax highlighting of Smarty syntax in template file"
Setup: "Already created tpl file"
- "Syntax highlighting"
- Copy the code below to tpl file
<h1 class="heading">{$sekce|escape:'html'}</h1> {if isset($user)}Hello {$foo[0].name|escape:'html'}{/if} <div class="text"> {foreach from=$articles item=article} <div class="content"> {$article.perex|escape:'html'|lower} </div> {/foreach} </div>
- EXPECTED RESULT: The syntax is highlighted as on the picture below, no errors are shown.
- "Tag matching"
- Use the code above
- Try tu put cursor into various smarty tags. e.g. {/fore|ach}
- EXPECTED RESULT: "Corresponding start/end tag and selected tag are highlighted"
- "Syntax error"
- Use the code below
- EXPECTED RESULT: NetBeans shows error about unclosed if tag
{if isset($team->bugSets)} <script> var a = 1; </script>
Test suite: Code Completion
Purpose: "This test suite checks code completion of Smarty tags"
Setup: "Already created tpl file"
{foreach from=$array key=key item=val} {$val|} {/foreach}
- "Smarty keywords"
- In tpl file, type { and invoke CC.
- List of Smarty tags should be offered.
- Type "fo" so in result you should have "{fo".
- Offered list is reduce to 3 items (for, foreach and foreachelse) and help window displays help text for "foreach".
- Press Enter, {foreach should be completed.
- Press Space and invoke CC using Ctrl+Space.
- Four items are offered: from, item, key and value. Pick one and press Enter.
- Selected item is completed.
- Finnish the code to looked like the one above.
- Invoke code completion after "|".
- List of modifiers is offered (cat, html...). Pick one and press Enter
- EXPECTED RESULT: "Code completion works as described"
- "Custom delimiters - project scope"
- Right click on project node in Projects window, select properties.
- Select Smarty section (below Frameworks).
- Change both delimiters to custom values.
- Open tpl file and type the open delimiter you've just defined and try code completion (tpl files have to be reopened to apply changes)
- EXPECTED RESULT: "Code completion works the same way like in previous test case."
- "Custom delimiters - project scope II"
- Having open the project from previous test case, create new PHP project and add Smarty template file to it.
- Open template file
- Type "{" and invoke code completion
- EXPECTED RESULT: "Code completion works and setting custom delimiters to other project doesn't effect other projects."
- "Custom delimiters - IDE scope"
- Having open both projects from previous test cases, go to Tools|Options|PHP|Smarty.
- Change both delimiters to custom values.
- Open tpl file from project that doesn't have set custom delimeters.
- Type open delimiter you define in Tools|Options... and invoke code completion.
- EXPECTED RESULT: "Code completion works and project that doesn't have set custom delimiters via project properties uses settings from IDE."
Test suite: HTML in template files
- "HTML editing in template file"
- Open tpl file.
- Check common features for HTML tags in tpl file (code completion, code folding, syntax highlighting, reformatting) as described in TS_60_HTMLeditor
- EXPECTED RESULT: "HTML editing works the same way as in html file."
Test suite: PHP in template files
- "PHP editing in template file"
- Open tpl file.
- Use {php} and {/php} to define php code block (note that if you set custom delimiters, use them instead if "{" and "}")
- EXPECTED RESULT: "PHP syntax is highlighted as in common php file"
Test suite: Configurable toggle comment
- "Smarty comment everywhere"
- Open tpl file.
- Use the code below
- Place cursor inside the div and press Ctrl+/ to toggle comment
- EXPECTED RESULT: Result looks same as below
{if isset($team->bugSets)} <div>Test</div> {/if}
Result:
{if isset($team->bugSets)} {*<div>Test</div>*} {/if}
- "Language sensitive comment I"
- Open tpl file.
- Go to Tools|Options|PHP|Smarty and check "language sensitive"
- Use the code below
- Place cursor inside the div and press Ctrl+/ to toggle comment
- EXPECTED RESULT: Result looks same as below
{if isset($team->bugSets)} <div>Test</div> {/if}
Result:
{if isset($team->bugSets)} <!--<div>Test</div>--> {/if}
- "Language sensitive comment II"
- Open tpl file.
- Go to Tools|Options|PHP|Smarty and check "language sensitive"
- Use the code below
- Place cursor inside the div and press Ctrl+/ to toggle comment
- EXPECTED RESULT: Result looks same as below
{if isset($team->bugSets)} <script> var a = 1; </script> {/if}
Result:
{if isset($team->bugSets)} <script> // var a = 1; </script> {/if}