-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test setup and phpcs check to circle ci (#3)
- Loading branch information
1 parent
e19b1a1
commit f975ddd
Showing
11 changed files
with
367 additions
and
10 deletions.
There are no files selected for viewing
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,22 @@ | ||
version: 2 | ||
|
||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/php:5.6-node-browsers | ||
|
||
steps: | ||
- checkout | ||
- run: sudo composer self-update | ||
- restore_cache: | ||
keys: | ||
- composer-v1-{{ checksum "composer.json" }} | ||
- composer-v1- | ||
- run: composer install -n --prefer-dist | ||
- save_cache: | ||
key: composer-v1-{{ checksum "composer.json" }} | ||
paths: | ||
- vendor | ||
- ~/.composer/cache | ||
- run: php -d memory_limit=2G ./vendor/bin/phpunit | ||
- run: php -n -d memory_limit=2G ./vendor/bin/php-cs-fixer fix --verbose --diff --diff-format=udiff --dry-run |
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,6 @@ | ||
.github export-ignore | ||
.circleci export-ignore | ||
.gitignore export-ignore | ||
.php_cs export-ignore | ||
.gitattributes export-ignore | ||
/tests export-ignore |
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 |
---|---|---|
|
@@ -3,10 +3,14 @@ | |
/composer.phar | ||
/vendor | ||
|
||
# Cache | ||
/.php_cs.cache | ||
|
||
# IDEs | ||
/.idea | ||
*.iml | ||
*~ | ||
|
||
# System files | ||
.DS_Store | ||
*.swp |
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,21 @@ | ||
<?php | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@Symfony' => true, | ||
'ordered_imports' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
'php_unit_construct' => true, | ||
'phpdoc_align' => false, | ||
'class_definition' => [ | ||
'multiLineExtendsEachSingleLine' => true, | ||
] | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('Resources') | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
); |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit colors="true" bootstrap="./vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="Massive Twig Extensions"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,182 @@ | ||
<?php | ||
|
||
use Massive\Component\Web\ComponentTwigExtension; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ComponentTwigExtensionTest extends TestCase | ||
{ | ||
/** | ||
* @var ComponentTwigExtension | ||
*/ | ||
private $componentTwigExtension; | ||
|
||
public function setup() | ||
{ | ||
$this->componentTwigExtension = new ComponentTwigExtension(); | ||
} | ||
|
||
public function testRegisterComponent() | ||
{ | ||
$this->assertEquals('test-1', $this->componentTwigExtension->registerComponent('test')); | ||
|
||
$this->assertEquals( | ||
json_encode([ | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-1', | ||
'options' => new stdClass(), | ||
], | ||
]), | ||
$this->componentTwigExtension->getComponents() | ||
); | ||
} | ||
|
||
public function testRegisterMultipleComponent() | ||
{ | ||
$this->assertEquals('test-1', $this->componentTwigExtension->registerComponent('test')); | ||
$this->assertEquals('test-2', $this->componentTwigExtension->registerComponent('test')); | ||
|
||
$this->assertEquals( | ||
json_encode([ | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-1', | ||
'options' => new stdClass(), | ||
], | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-2', | ||
'options' => new stdClass(), | ||
], | ||
]), | ||
$this->componentTwigExtension->getComponents() | ||
); | ||
} | ||
|
||
public function testRegisterCustomIdComponent() | ||
{ | ||
$this->assertEquals('custom', $this->componentTwigExtension->registerComponent('test', ['id' => 'custom'])); | ||
|
||
$this->assertEquals( | ||
json_encode([ | ||
[ | ||
'name' => 'test', | ||
'id' => 'custom', | ||
'options' => (object) ['id' => 'custom'], | ||
], | ||
]), | ||
$this->componentTwigExtension->getComponents() | ||
); | ||
} | ||
|
||
public function testRegisterOptionComponent() | ||
{ | ||
$this->assertEquals('test-1', $this->componentTwigExtension->registerComponent('test', ['option1' => 'value1', 'option2' => 'value2'])); | ||
|
||
$this->assertEquals( | ||
json_encode([ | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-1', | ||
'options' => (object) [ | ||
'option1' => 'value1', | ||
'option2' => 'value2', | ||
], | ||
], | ||
]), | ||
$this->componentTwigExtension->getComponents() | ||
); | ||
} | ||
|
||
public function testRegisterComponentArray() | ||
{ | ||
$this->assertEquals('test-1', $this->componentTwigExtension->registerComponent('test')); | ||
|
||
$this->assertEquals( | ||
[ | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-1', | ||
'options' => new stdClass(), | ||
], | ||
], | ||
$this->componentTwigExtension->getComponents(false) | ||
); | ||
} | ||
|
||
public function testRegisterComponentClear() | ||
{ | ||
$this->assertEquals('test-1', $this->componentTwigExtension->registerComponent('test')); | ||
|
||
// Get components without clearing them. | ||
$this->assertEquals( | ||
[ | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-1', | ||
'options' => new stdClass(), | ||
], | ||
], | ||
$this->componentTwigExtension->getComponents(false, false) | ||
); | ||
|
||
// Get components with clearing. | ||
$this->assertEquals( | ||
[ | ||
[ | ||
'name' => 'test', | ||
'id' => 'test-1', | ||
'options' => new stdClass(), | ||
], | ||
], | ||
$this->componentTwigExtension->getComponents(false) | ||
); | ||
|
||
// Check if cleared correctly. | ||
$this->assertEquals([], $this->componentTwigExtension->getComponents(false)); | ||
} | ||
|
||
public function testComponentList() | ||
{ | ||
$this->componentTwigExtension->registerComponent('test'); | ||
$this->componentTwigExtension->registerComponent('test'); | ||
$this->componentTwigExtension->registerComponent('test2'); | ||
$this->componentTwigExtension->registerComponent('test3'); | ||
|
||
$componentList = $this->componentTwigExtension->getComponentList(); | ||
|
||
$this->assertCount(3, $componentList); | ||
$this->assertEquals(['test', 'test2', 'test3'], $componentList); | ||
} | ||
|
||
public function testCallService() | ||
{ | ||
$this->componentTwigExtension->callService('service', 'function', ['key' => 'value']); | ||
|
||
$this->assertEquals( | ||
json_encode([ | ||
[ | ||
'name' => 'service', | ||
'func' => 'function', | ||
'args' => [ | ||
'key' => 'value', | ||
], | ||
], | ||
]), | ||
$this->componentTwigExtension->getServices() | ||
); | ||
} | ||
|
||
public function testGetServices() | ||
{ | ||
$this->componentTwigExtension->callService('service', 'function', ['key' => 'value']); | ||
$this->componentTwigExtension->callService('service2', 'function', ['key' => 'value']); | ||
$this->componentTwigExtension->callService('service2', 'function', ['key' => 'value']); | ||
$this->componentTwigExtension->callService('service3', 'function', ['key' => 'value']); | ||
|
||
$servicesList = $this->componentTwigExtension->getServiceList(); | ||
|
||
$this->assertCount(3, $servicesList); | ||
$this->assertEquals(['service', 'service2', 'service3'], $servicesList); | ||
} | ||
} |
Oops, something went wrong.