-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added missing tests for Twig extenstions
- Loading branch information
Showing
9 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Twig\TwigFilter; | ||
use Twig\TwigFunction; | ||
|
||
class LanguageCodeTwigExtensionTest extends TestCase | ||
{ | ||
private LanguageCodeTwigExtension $extension; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->extension = new LanguageCodeTwigExtension(); | ||
} | ||
|
||
public function testGetFunctions(): void | ||
{ | ||
$functions = $this->extension->getFunctions(); | ||
|
||
$this->assertCount(1, $functions); | ||
|
||
$this->assertInstanceOf(TwigFunction::class, $functions[0]); | ||
$this->assertEquals('getFromLanguageCode', $functions[0]->getName()); | ||
} | ||
|
||
public function testGetFilters(): void | ||
{ | ||
$filters = $this->extension->getFilters(); | ||
|
||
$this->assertCount(1, $filters); | ||
|
||
$this->assertInstanceOf(TwigFilter::class, $filters[0]); | ||
$this->assertEquals('getFromLanguageCode', $filters[0]->getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Twig\TemplateWrapper; | ||
|
||
class TwigWrapperTest extends TestCase | ||
{ | ||
private TwigWrapper $twigWrapper; | ||
|
||
/** | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->twigWrapper = new TwigWrapper(PMF_TEST_DIR . '/assets/templates'); | ||
} | ||
|
||
/** | ||
* @throws TemplateException | ||
*/ | ||
public function testLoadTemplate(): void | ||
{ | ||
$templateFile = 'template.twig'; | ||
|
||
$result = $this->twigWrapper->loadTemplate($templateFile); | ||
|
||
$this->assertInstanceOf(TemplateWrapper::class, $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Twig\TwigFilter; | ||
|
||
class UserNameTwigExtensionTest extends TestCase | ||
{ | ||
private UserNameTwigExtension $extension; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->extension = new UserNameTwigExtension(); | ||
} | ||
|
||
public function testGetFilters(): void | ||
{ | ||
$filters = $this->extension->getFilters(); | ||
|
||
$this->assertCount(1, $filters); | ||
|
||
$this->assertInstanceOf(TwigFilter::class, $filters[0]); | ||
$this->assertEquals('userName', $filters[0]->getName()); | ||
} | ||
} |