From fe8b03ae39d339bc2d2e7f0284ef1a910204a830 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 6 Oct 2019 16:48:33 +0200 Subject: [PATCH] Allow mutual requirement of 1.x versions split: c2f190453dff9d3a7729449ecb900d2326ab4a11 --- .codeclimate.yml | 22 - .multi-tester.yml | 28 - .travis.yml | 33 +- ...erModule.php => AbstractCompilerModule.php | 0 src/Phug/Compiler.php => Compiler.php | 0 .../AbstractNodeCompiler.php | 0 .../Element/BlockElement.php | 0 .../Event/CompileEvent.php | 0 .../Event/ElementEvent.php | 0 .../Compiler => Compiler}/Event/NodeEvent.php | 0 .../Event/OutputEvent.php | 0 {src/Phug/Compiler => Compiler}/Layout.php | 0 .../Locator/FileLocator.php | 0 .../LocatorInterface.php | 0 .../AbstractStatementNodeCompiler.php | 0 .../AssignmentListNodeCompiler.php | 0 .../NodeCompiler/AssignmentNodeCompiler.php | 0 .../AttributeListNodeCompiler.php | 0 .../NodeCompiler/AttributeNodeCompiler.php | 0 .../NodeCompiler/BlockNodeCompiler.php | 0 .../NodeCompiler/CaseNodeCompiler.php | 0 .../NodeCompiler/CodeNodeCompiler.php | 0 .../NodeCompiler/CommentNodeCompiler.php | 0 .../NodeCompiler/ConditionalNodeCompiler.php | 0 .../NodeCompiler/DoNodeCompiler.php | 0 .../NodeCompiler/DoctypeNodeCompiler.php | 0 .../NodeCompiler/DocumentNodeCompiler.php | 0 .../NodeCompiler/EachNodeCompiler.php | 0 .../NodeCompiler/ElementNodeCompiler.php | 0 .../NodeCompiler/ExpressionNodeCompiler.php | 0 .../NodeCompiler/FilterNodeCompiler.php | 0 .../NodeCompiler/ForNodeCompiler.php | 0 .../NodeCompiler/ImportNodeCompiler.php | 0 .../NodeCompiler/KeywordNodeCompiler.php | 0 .../NodeCompiler/MixinCallNodeCompiler.php | 0 .../NodeCompiler/MixinNodeCompiler.php | 0 .../NodeCompiler/TextNodeCompiler.php | 0 .../NodeCompiler/VariableNodeCompiler.php | 0 .../NodeCompiler/WhenNodeCompiler.php | 0 .../NodeCompiler/WhileNodeCompiler.php | 0 .../NodeCompiler/YieldNodeCompiler.php | 0 .../NodeCompilerInterface.php | 0 .../Util/YieldHandlerTrait.php | 0 .../CompilerEvent.php => CompilerEvent.php | 0 ...ilerException.php => CompilerException.php | 0 ...ilerInterface.php => CompilerInterface.php | 0 ...terface.php => CompilerModuleInterface.php | 0 composer.json | 13 +- phpcs.xml | 7 + phpunit.xml | 21 + tests/Phug/AbstractCompilerTest.php | 181 ------ .../Phug/Compiler/Locator/FileLocatorTest.php | 82 --- .../AssignmentListNodeCompilerTest.php | 29 - .../AssignmentNodeCompilerTest.php | 45 -- .../AttributeListCompilerTest.php | 29 - .../AttributeNodeCompilerTest.php | 109 ---- .../NodeCompiler/BlockNodeCompilerTest.php | 71 --- .../TestBlockNodeCompiler.php | 19 - .../NodeCompiler/CaseNodeCompilerTest.php | 88 --- .../NodeCompiler/CodeNodeCompilerTest.php | 62 --- .../NodeCompiler/CommentNodeCompilerTest.php | 44 -- .../ConditionalNodeCompilerTest.php | 75 --- .../NodeCompiler/DoNodeCompilerTest.php | 29 - .../NodeCompiler/DoctypeNodeCompilerTest.php | 44 -- .../NodeCompiler/DocumentNodeCompilerTest.php | 37 -- .../NodeCompiler/EachNodeCompilerTest.php | 225 -------- .../NodeCompiler/ElementNodeCompilerTest.php | 51 -- .../ExpressionNodeCompilerTest.php | 44 -- .../NodeCompiler/FilterNodeCompilerTest.php | 207 ------- .../NodeCompiler/ForNodeCompilerTest.php | 158 ------ .../NodeCompiler/ImportNodeCompilerTest.php | 332 ----------- .../NodeCompiler/KeywordNodeCompilerTest.php | 63 --- .../MixinCallNodeCompilerTest.php | 355 ------------ .../NodeCompiler/MixinNodeCompilerTest.php | 107 ---- .../NodeCompiler/TextNodeCompilerTest.php | 78 --- .../NodeCompiler/VariableNodeCompilerTest.php | 54 -- .../NodeCompiler/WhenNodeCompilerTest.php | 29 - .../NodeCompiler/WhileNodeCompilerTest.php | 99 ---- .../NodeCompiler/YieldNodeCompilerTest.php | 29 - tests/Phug/CompilerModuleTest.php | 112 ---- tests/Phug/CompilerTest.php | 521 ------------------ tests/Phug/Node/TestNode.php | 9 - tests/Phug/TestCompiler.php | 15 - tests/templates/attrs.unescaped.pug | 3 - tests/templates/auto-yield.pug | 4 - tests/templates/auxiliary/img.pug | 3 - tests/templates/auxiliary/include.nested.pug | 3 - tests/templates/auxiliary/include.simple.pug | 4 - tests/templates/auxiliary/layout.pug | 6 - tests/templates/auxiliary/sub-layout.pug | 5 - tests/templates/auxiliary/switch.pug | 3 - tests/templates/base.pug | 10 - tests/templates/dialog.pug | 6 - .../example-structure/layouts/base.pug | 3 - .../mixins/lib1/first-module.pug | 3 - .../mixins/lib2/second-module.pug | 3 - .../example-structure/views/base.pug | 5 - .../example-structure/views/index.pug | 5 - .../example-structure/views/mixins.pug | 10 - .../example-structure/views/test/index.pug | 5 - tests/templates/inc-children.pug | 4 - tests/templates/inc-multi.pug | 7 - tests/templates/inc-no-extension.pug | 1 - tests/templates/inc-page.pug | 2 - tests/templates/inc-yield.pug | 3 - tests/templates/inc.pug | 1 - tests/templates/include-wrong-path.pug | 1 - tests/templates/includes-option.pug | 4 - tests/templates/includes-with-ext-js.pug | 3 - tests/templates/inheritance.alert-dialog.pug | 6 - .../templates/inheritance.extend.mixins.html | 9 - tests/templates/inheritance.extend.mixins.pug | 11 - tests/templates/issue26/error-test.html | 1 - tests/templates/issue26/error-test.pug | 5 - tests/templates/issue26/layout.pug | 5 - tests/templates/issue26/test-mixin.pug | 2 - tests/templates/javascript-new-lines.js | 1 - tests/templates/layout.pug | 5 - tests/templates/lower.txt | 1 - tests/templates/mixin-double-block.pug | 15 - tests/templates/mixin.attrs.html | 32 -- tests/templates/mixin.attrs.pug | 59 -- tests/templates/mixin.blocks.html | 34 -- tests/templates/mixin.blocks.pug | 44 -- tests/templates/mixins-test.pug | 17 - tests/templates/mixins.pug | 9 - tests/templates/nested-mixins-local-init.pug | 8 - tests/templates/nested-mixins.html | 0 tests/templates/nested-mixins.pug | 7 - tests/templates/noextension | 1 - tests/templates/page.pug | 4 - tests/templates/replace.pug | 4 - tests/templates/window.pug | 4 - tests/templates/yield-in-sub-include.html | 7 - tests/templates/yield-in-sub-include.pug | 4 - tests/templates/yield.pug | 3 - 136 files changed, 50 insertions(+), 3911 deletions(-) delete mode 100644 .codeclimate.yml delete mode 100644 .multi-tester.yml rename src/Phug/AbstractCompilerModule.php => AbstractCompilerModule.php (100%) rename src/Phug/Compiler.php => Compiler.php (100%) rename {src/Phug/Compiler => Compiler}/AbstractNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/Element/BlockElement.php (100%) rename {src/Phug/Compiler => Compiler}/Event/CompileEvent.php (100%) rename {src/Phug/Compiler => Compiler}/Event/ElementEvent.php (100%) rename {src/Phug/Compiler => Compiler}/Event/NodeEvent.php (100%) rename {src/Phug/Compiler => Compiler}/Event/OutputEvent.php (100%) rename {src/Phug/Compiler => Compiler}/Layout.php (100%) rename {src/Phug/Compiler => Compiler}/Locator/FileLocator.php (100%) rename {src/Phug/Compiler => Compiler}/LocatorInterface.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/AbstractStatementNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/AssignmentListNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/AssignmentNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/AttributeListNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/AttributeNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/BlockNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/CaseNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/CodeNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/CommentNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/ConditionalNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/DoNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/DoctypeNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/DocumentNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/EachNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/ElementNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/ExpressionNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/FilterNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/ForNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/ImportNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/KeywordNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/MixinCallNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/MixinNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/TextNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/VariableNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/WhenNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/WhileNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompiler/YieldNodeCompiler.php (100%) rename {src/Phug/Compiler => Compiler}/NodeCompilerInterface.php (100%) rename {src/Phug/Compiler => Compiler}/Util/YieldHandlerTrait.php (100%) rename src/Phug/CompilerEvent.php => CompilerEvent.php (100%) rename src/Phug/CompilerException.php => CompilerException.php (100%) rename src/Phug/CompilerInterface.php => CompilerInterface.php (100%) rename src/Phug/CompilerModuleInterface.php => CompilerModuleInterface.php (100%) create mode 100644 phpcs.xml create mode 100644 phpunit.xml delete mode 100644 tests/Phug/AbstractCompilerTest.php delete mode 100644 tests/Phug/Compiler/Locator/FileLocatorTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/AssignmentListNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/AssignmentNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/AttributeListCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/AttributeNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest/TestBlockNodeCompiler.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/CaseNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/CodeNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/CommentNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/ConditionalNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/DoNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/DoctypeNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/DocumentNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/EachNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/ElementNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/ExpressionNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/FilterNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/ForNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/ImportNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/KeywordNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/MixinCallNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/MixinNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/TextNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/VariableNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/WhenNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/WhileNodeCompilerTest.php delete mode 100644 tests/Phug/Compiler/NodeCompiler/YieldNodeCompilerTest.php delete mode 100644 tests/Phug/CompilerModuleTest.php delete mode 100644 tests/Phug/CompilerTest.php delete mode 100644 tests/Phug/Node/TestNode.php delete mode 100644 tests/Phug/TestCompiler.php delete mode 100644 tests/templates/attrs.unescaped.pug delete mode 100644 tests/templates/auto-yield.pug delete mode 100644 tests/templates/auxiliary/img.pug delete mode 100644 tests/templates/auxiliary/include.nested.pug delete mode 100644 tests/templates/auxiliary/include.simple.pug delete mode 100644 tests/templates/auxiliary/layout.pug delete mode 100644 tests/templates/auxiliary/sub-layout.pug delete mode 100644 tests/templates/auxiliary/switch.pug delete mode 100644 tests/templates/base.pug delete mode 100644 tests/templates/dialog.pug delete mode 100644 tests/templates/example-structure/layouts/base.pug delete mode 100644 tests/templates/example-structure/mixins/lib1/first-module.pug delete mode 100644 tests/templates/example-structure/mixins/lib2/second-module.pug delete mode 100644 tests/templates/example-structure/views/base.pug delete mode 100644 tests/templates/example-structure/views/index.pug delete mode 100644 tests/templates/example-structure/views/mixins.pug delete mode 100644 tests/templates/example-structure/views/test/index.pug delete mode 100644 tests/templates/inc-children.pug delete mode 100644 tests/templates/inc-multi.pug delete mode 100644 tests/templates/inc-no-extension.pug delete mode 100644 tests/templates/inc-page.pug delete mode 100644 tests/templates/inc-yield.pug delete mode 100644 tests/templates/inc.pug delete mode 100644 tests/templates/include-wrong-path.pug delete mode 100644 tests/templates/includes-option.pug delete mode 100644 tests/templates/includes-with-ext-js.pug delete mode 100644 tests/templates/inheritance.alert-dialog.pug delete mode 100644 tests/templates/inheritance.extend.mixins.html delete mode 100644 tests/templates/inheritance.extend.mixins.pug delete mode 100644 tests/templates/issue26/error-test.html delete mode 100644 tests/templates/issue26/error-test.pug delete mode 100644 tests/templates/issue26/layout.pug delete mode 100644 tests/templates/issue26/test-mixin.pug delete mode 100644 tests/templates/javascript-new-lines.js delete mode 100644 tests/templates/layout.pug delete mode 100644 tests/templates/lower.txt delete mode 100644 tests/templates/mixin-double-block.pug delete mode 100644 tests/templates/mixin.attrs.html delete mode 100644 tests/templates/mixin.attrs.pug delete mode 100644 tests/templates/mixin.blocks.html delete mode 100644 tests/templates/mixin.blocks.pug delete mode 100644 tests/templates/mixins-test.pug delete mode 100644 tests/templates/mixins.pug delete mode 100644 tests/templates/nested-mixins-local-init.pug delete mode 100644 tests/templates/nested-mixins.html delete mode 100644 tests/templates/nested-mixins.pug delete mode 100644 tests/templates/noextension delete mode 100644 tests/templates/page.pug delete mode 100644 tests/templates/replace.pug delete mode 100644 tests/templates/window.pug delete mode 100644 tests/templates/yield-in-sub-include.html delete mode 100644 tests/templates/yield-in-sub-include.pug delete mode 100644 tests/templates/yield.pug diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 47f1cfe..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -version: "2" -plugins: - duplication: - enabled: false - fixme: - enabled: true - phpmd: - enabled: true - checks: - Design/EvalExpression: - enabled: false - UnusedFormalParameter: - enabled: false - phpcodesniffer: - enabled: true - sonar-php: - enabled: true - phan: - enabled: true -exclude_patterns: -- 'tests/' diff --git a/.multi-tester.yml b/.multi-tester.yml deleted file mode 100644 index e852bbb..0000000 --- a/.multi-tester.yml +++ /dev/null @@ -1,28 +0,0 @@ -phug/renderer: - script: vendor/bin/phpunit -c ./vendor/phug/dev-tool/config/ - -phug/phug: - script: vendor/bin/phpunit -c ./vendor/phug/dev-tool/config/ - -pug-php/pug: default - -pug/bemto: default - -pug-php/pug-assets: default - -pug-php/pug-minify: default - -pug/slim: default - -pug/twig: - script: vendor/bin/phpunit -c ./vendor/phug/dev-tool/config/ - -ci-pug/ci-pug: default - -bkwld/laravel-pug: - install: - - php tests/setDependenciesVersions.php 5.8.* ^3.0 - - composer update --no-interaction - script: LARAVEL_VERSION=5.8 ./vendor/bin/phpunit --no-coverage - -pug/yii2: default diff --git a/.travis.yml b/.travis.yml index 591dd51..3d92d60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ - language: php git: @@ -6,26 +5,30 @@ git: matrix: include: - - php: 5.5 - dist: precise - - php: 5.6 - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: 7.3 - php: 7.4snapshot - php: 7.3 - env: MULTITEST='on' + env: COVERAGE=on + dist: trusty + - php: 7.3 + env: STYLECHECK=on install: - - travis_retry composer clear-cache - - if [ "$MULTITEST" = "on" ]; then composer require --no-update kylekatarnls/multi-tester; fi; - - travis_retry composer self-update - - travis_retry composer install + - composer self-update + - if [[ "$STYLECHECK" != "on" ]]; then composer require phpunit/phpunit:^7 js-phpize/js-phpize:^2 pug-php/pug-filter-coffee-script:^1 phug/split --no-update; fi; + - if [[ "$STYLECHECK" = "on" ]]; then composer require squizlabs/php_codesniffer --no-update; fi; + - composer install + - | + if [[ "$STYLECHECK" != "on" ]]; then + mkdir -p tests/Phug && \ + vendor/bin/split copy https://github.com/phug-php/phug.git tests/Phug/ --filters=tests/Phug/Compiler,tests/Phug/Node,tests/Phug/AbstractCompilerTest.php,tests/Phug/CompilerModuleTest.php,tests/Phug/CompilerTest.php,tests/Phug/TestCompiler.php; + mkdir -p tests/templates && \ + vendor/bin/split copy https://github.com/phug-php/phug.git tests/ --filters=tests/templates; + fi; script: - - if [ "$MULTITEST" != "on" ]; then vendor/bin/phug-dev check --report --coverage-php-version=5.6; fi; - - if [ "$MULTITEST" = "on" ]; then vendor/bin/multi-tester --verbose; fi; + - if [[ "$STYLECHECK" != "on" && "$COVERAGE" != "on" ]]; then vendor/bin/phpunit; fi; + - if [[ "$COVERAGE" = "on" ]]; then vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml; fi; + - if [[ "$STYLECHECK" = "on" ]]; then vendor/bin/phpcs --ignore=*.js Compiler AbstractCompilerModule.php Compiler.php CompilerEvent.php CompilerException.php CompilerInterface.php CompilerModuleInterface.php; fi; notifications: slack: phug:nzXFnxhU14RWK2EQSDL0u08z diff --git a/src/Phug/AbstractCompilerModule.php b/AbstractCompilerModule.php similarity index 100% rename from src/Phug/AbstractCompilerModule.php rename to AbstractCompilerModule.php diff --git a/src/Phug/Compiler.php b/Compiler.php similarity index 100% rename from src/Phug/Compiler.php rename to Compiler.php diff --git a/src/Phug/Compiler/AbstractNodeCompiler.php b/Compiler/AbstractNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/AbstractNodeCompiler.php rename to Compiler/AbstractNodeCompiler.php diff --git a/src/Phug/Compiler/Element/BlockElement.php b/Compiler/Element/BlockElement.php similarity index 100% rename from src/Phug/Compiler/Element/BlockElement.php rename to Compiler/Element/BlockElement.php diff --git a/src/Phug/Compiler/Event/CompileEvent.php b/Compiler/Event/CompileEvent.php similarity index 100% rename from src/Phug/Compiler/Event/CompileEvent.php rename to Compiler/Event/CompileEvent.php diff --git a/src/Phug/Compiler/Event/ElementEvent.php b/Compiler/Event/ElementEvent.php similarity index 100% rename from src/Phug/Compiler/Event/ElementEvent.php rename to Compiler/Event/ElementEvent.php diff --git a/src/Phug/Compiler/Event/NodeEvent.php b/Compiler/Event/NodeEvent.php similarity index 100% rename from src/Phug/Compiler/Event/NodeEvent.php rename to Compiler/Event/NodeEvent.php diff --git a/src/Phug/Compiler/Event/OutputEvent.php b/Compiler/Event/OutputEvent.php similarity index 100% rename from src/Phug/Compiler/Event/OutputEvent.php rename to Compiler/Event/OutputEvent.php diff --git a/src/Phug/Compiler/Layout.php b/Compiler/Layout.php similarity index 100% rename from src/Phug/Compiler/Layout.php rename to Compiler/Layout.php diff --git a/src/Phug/Compiler/Locator/FileLocator.php b/Compiler/Locator/FileLocator.php similarity index 100% rename from src/Phug/Compiler/Locator/FileLocator.php rename to Compiler/Locator/FileLocator.php diff --git a/src/Phug/Compiler/LocatorInterface.php b/Compiler/LocatorInterface.php similarity index 100% rename from src/Phug/Compiler/LocatorInterface.php rename to Compiler/LocatorInterface.php diff --git a/src/Phug/Compiler/NodeCompiler/AbstractStatementNodeCompiler.php b/Compiler/NodeCompiler/AbstractStatementNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/AbstractStatementNodeCompiler.php rename to Compiler/NodeCompiler/AbstractStatementNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/AssignmentListNodeCompiler.php b/Compiler/NodeCompiler/AssignmentListNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/AssignmentListNodeCompiler.php rename to Compiler/NodeCompiler/AssignmentListNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/AssignmentNodeCompiler.php b/Compiler/NodeCompiler/AssignmentNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/AssignmentNodeCompiler.php rename to Compiler/NodeCompiler/AssignmentNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/AttributeListNodeCompiler.php b/Compiler/NodeCompiler/AttributeListNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/AttributeListNodeCompiler.php rename to Compiler/NodeCompiler/AttributeListNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/AttributeNodeCompiler.php b/Compiler/NodeCompiler/AttributeNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/AttributeNodeCompiler.php rename to Compiler/NodeCompiler/AttributeNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/BlockNodeCompiler.php b/Compiler/NodeCompiler/BlockNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/BlockNodeCompiler.php rename to Compiler/NodeCompiler/BlockNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/CaseNodeCompiler.php b/Compiler/NodeCompiler/CaseNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/CaseNodeCompiler.php rename to Compiler/NodeCompiler/CaseNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/CodeNodeCompiler.php b/Compiler/NodeCompiler/CodeNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/CodeNodeCompiler.php rename to Compiler/NodeCompiler/CodeNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/CommentNodeCompiler.php b/Compiler/NodeCompiler/CommentNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/CommentNodeCompiler.php rename to Compiler/NodeCompiler/CommentNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/ConditionalNodeCompiler.php b/Compiler/NodeCompiler/ConditionalNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/ConditionalNodeCompiler.php rename to Compiler/NodeCompiler/ConditionalNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/DoNodeCompiler.php b/Compiler/NodeCompiler/DoNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/DoNodeCompiler.php rename to Compiler/NodeCompiler/DoNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/DoctypeNodeCompiler.php b/Compiler/NodeCompiler/DoctypeNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/DoctypeNodeCompiler.php rename to Compiler/NodeCompiler/DoctypeNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/DocumentNodeCompiler.php b/Compiler/NodeCompiler/DocumentNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/DocumentNodeCompiler.php rename to Compiler/NodeCompiler/DocumentNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/EachNodeCompiler.php b/Compiler/NodeCompiler/EachNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/EachNodeCompiler.php rename to Compiler/NodeCompiler/EachNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/ElementNodeCompiler.php b/Compiler/NodeCompiler/ElementNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/ElementNodeCompiler.php rename to Compiler/NodeCompiler/ElementNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/ExpressionNodeCompiler.php b/Compiler/NodeCompiler/ExpressionNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/ExpressionNodeCompiler.php rename to Compiler/NodeCompiler/ExpressionNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/FilterNodeCompiler.php b/Compiler/NodeCompiler/FilterNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/FilterNodeCompiler.php rename to Compiler/NodeCompiler/FilterNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/ForNodeCompiler.php b/Compiler/NodeCompiler/ForNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/ForNodeCompiler.php rename to Compiler/NodeCompiler/ForNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/ImportNodeCompiler.php b/Compiler/NodeCompiler/ImportNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/ImportNodeCompiler.php rename to Compiler/NodeCompiler/ImportNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/KeywordNodeCompiler.php b/Compiler/NodeCompiler/KeywordNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/KeywordNodeCompiler.php rename to Compiler/NodeCompiler/KeywordNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/MixinCallNodeCompiler.php b/Compiler/NodeCompiler/MixinCallNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/MixinCallNodeCompiler.php rename to Compiler/NodeCompiler/MixinCallNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/MixinNodeCompiler.php b/Compiler/NodeCompiler/MixinNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/MixinNodeCompiler.php rename to Compiler/NodeCompiler/MixinNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/TextNodeCompiler.php b/Compiler/NodeCompiler/TextNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/TextNodeCompiler.php rename to Compiler/NodeCompiler/TextNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/VariableNodeCompiler.php b/Compiler/NodeCompiler/VariableNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/VariableNodeCompiler.php rename to Compiler/NodeCompiler/VariableNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/WhenNodeCompiler.php b/Compiler/NodeCompiler/WhenNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/WhenNodeCompiler.php rename to Compiler/NodeCompiler/WhenNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/WhileNodeCompiler.php b/Compiler/NodeCompiler/WhileNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/WhileNodeCompiler.php rename to Compiler/NodeCompiler/WhileNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompiler/YieldNodeCompiler.php b/Compiler/NodeCompiler/YieldNodeCompiler.php similarity index 100% rename from src/Phug/Compiler/NodeCompiler/YieldNodeCompiler.php rename to Compiler/NodeCompiler/YieldNodeCompiler.php diff --git a/src/Phug/Compiler/NodeCompilerInterface.php b/Compiler/NodeCompilerInterface.php similarity index 100% rename from src/Phug/Compiler/NodeCompilerInterface.php rename to Compiler/NodeCompilerInterface.php diff --git a/src/Phug/Compiler/Util/YieldHandlerTrait.php b/Compiler/Util/YieldHandlerTrait.php similarity index 100% rename from src/Phug/Compiler/Util/YieldHandlerTrait.php rename to Compiler/Util/YieldHandlerTrait.php diff --git a/src/Phug/CompilerEvent.php b/CompilerEvent.php similarity index 100% rename from src/Phug/CompilerEvent.php rename to CompilerEvent.php diff --git a/src/Phug/CompilerException.php b/CompilerException.php similarity index 100% rename from src/Phug/CompilerException.php rename to CompilerException.php diff --git a/src/Phug/CompilerInterface.php b/CompilerInterface.php similarity index 100% rename from src/Phug/CompilerInterface.php rename to CompilerInterface.php diff --git a/src/Phug/CompilerModuleInterface.php b/CompilerModuleInterface.php similarity index 100% rename from src/Phug/CompilerModuleInterface.php rename to CompilerModuleInterface.php diff --git a/composer.json b/composer.json index cbad008..3dd9d60 100644 --- a/composer.json +++ b/composer.json @@ -21,19 +21,14 @@ "minimum-stability": "stable", "require": { "php": ">=5.5.0", - "phug/util": "^0.4.0", - "phug/formatter": "^0.5.50", + "phug/util": "^0.4.0 || ^1.0", + "phug/formatter": "^0.5.50 || ^1.0", "phug/dependency-injection": "^1.1.2", - "phug/parser": "^0.5.0" - }, - "require-dev": { - "phug/dev-tool": "^0.1.0", - "js-phpize/js-phpize": "^1.4", - "pug-php/pug-filter-coffee-script": "^1.2" + "phug/parser": "^0.5.0 || ^1.0" }, "autoload": { "psr-4": { - "": "./src" + "Phug\\": "" } }, "bin": [], diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..af4e03e --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,7 @@ + + + + *.php + + . + \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..61f4353 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,21 @@ + + + + + tests + + + + + src + + + diff --git a/tests/Phug/AbstractCompilerTest.php b/tests/Phug/AbstractCompilerTest.php deleted file mode 100644 index 1a64677..0000000 --- a/tests/Phug/AbstractCompilerTest.php +++ /dev/null @@ -1,181 +0,0 @@ -expectExceptionMessage($message); - - return; - } - - $this->setExpectedException(Exception::class, $message, null); - } - - public function setUp() - { - $this->compiler = new Compiler([ - 'paths' => [__DIR__.'/../templates'], - 'patterns' => [ - 'expression_in_text' => '%s', - ], - ]); - } - - protected function enableJsPhpize() - { - $compiler = $this->compiler; - - $compiler = new Compiler([ - 'paths' => [__DIR__.'/../templates'], - 'patterns' => [ - 'expression_in_text' => '%s', - 'transform_expression' => function ($jsCode) use (&$compiler) { - /** @var JsPhpize $jsPhpize */ - $jsPhpize = $compiler->getOption('jsphpize_engine'); - - try { - $phpCode = trim($jsPhpize->compile($jsCode)); - $phpCode = preg_replace('/\{\s*\}$/', '', $phpCode); - $phpCode = preg_replace( - '/^(?attach(CompilerEvent::COMPILE, function () use ($compiler) { - $compiler->setOption('jsphpize_engine', new JsPhpize([ - 'catchDependencies' => true, - ])); - }); - - $compiler->attach(CompilerEvent::OUTPUT, function (Compiler\Event\OutputEvent $event) use ($compiler) { - - /** @var JsPhpize $jsPhpize */ - $jsPhpize = $compiler->getOption('jsphpize_engine'); - $dependencies = $jsPhpize->compileDependencies(); - if ($dependencies !== '') { - $event->setOutput($compiler->getFormatter()->handleCode($dependencies).$event->getOutput()); - } - $jsPhpize->flushDependencies(); - $compiler->unsetOption('jsphpize_engine'); - }); - - $this->compiler = $compiler; - } - - protected function implodeLines($str) - { - return preg_replace_callback('/(\s+[a-z0-9:_-]+="(?:\\\\[\\S\\s]|[^"\\\\])*")+/', function ($matches) { - $attributes = []; - $input = $matches[0]; - while (mb_strlen($input) && preg_match( - '/^\s+([a-z0-9:_-]+)="((?:\\\\[\\S\\s]|[^"\\\\])*)"/', - $input, - $match - )) { - if ($match[1] === 'class') { - $classes = explode(' ', $match[2]); - sort($classes); - $match[2] = implode(' ', $classes); - } - $attributes[] = trim($match[1]).'="'.$match[2].'"'; - $input = mb_substr($input, mb_strlen($match[0])); - } - sort($attributes); - - return ' '.implode(' ', $attributes); - }, is_string($str) ? $str : implode('', $str)); - } - - protected function assertSameLines($expected, $actual) - { - self::assertSame($this->implodeLines($expected), $this->implodeLines($actual)); - } - - protected function assertCompile($expected, $actual, array $options = []) - { - $compiler = clone $this->compiler; - $compiler->setOptionsRecursive($options); - - return $this->assertSameLines($expected, $compiler->compile($this->implodeLines($actual))); - } - - protected function assertCompileFile($expected, $actual) - { - return $this->assertSameLines($expected, $this->compiler->compileFile($actual)); - } - - protected function getRenderedHtml($php, array $variables = []) - { - if (getenv('LOG_COMPILE')) { - file_put_contents('temp.php', $php); - } - extract($variables); - ob_start(); - eval('?>'.$php); - $actual = ob_get_contents(); - ob_end_clean(); - - return $actual; - } - - protected function render($actual, array $options = [], array $variables = []) - { - $compiler = $this->compiler; - $compiler->setOptionsRecursive($options); - $php = $compiler->compile($this->implodeLines($actual)); - - return $this->getRenderedHtml($php, $variables); - } - - protected function assertRender($expected, $actual, array $options = [], array $variables = []) - { - $actual = $this->render($actual, $options, $variables); - - return $this->assertSameLines($expected, $actual); - } - - protected function assertRenderFile($expected, $actual, array $options = [], array $variables = []) - { - $compiler = $this->compiler; - $compiler->setOptionsRecursive($options); - $php = $compiler->compileFile($actual); - $actual = preg_replace( - '/\s(class|id)=""/', - '', - $this->getRenderedHtml($php, $variables) - ); - - return $this->assertSameLines($expected, $actual); - } -} diff --git a/tests/Phug/Compiler/Locator/FileLocatorTest.php b/tests/Phug/Compiler/Locator/FileLocatorTest.php deleted file mode 100644 index bfdf12b..0000000 --- a/tests/Phug/Compiler/Locator/FileLocatorTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - */ - public function testLocate() - { - $base = __DIR__.'/../../../templates/example-structure'; - $paths = ["$base/layouts", "$base/mixins/lib1", "$base/mixins/lib2", "$base/views"]; - $extensions = ['.pug']; - - $locator = new FileLocator(); - - self::assertFileExists($locator->locate('base', $paths, $extensions)); - self::assertStringEndsWith( - '/views/base.pug', - str_replace('\\', '/', $locator->locate('base', $paths, $extensions)) - ); - self::assertFileExists($locator->locate('base.pug', $paths, $extensions)); - self::assertStringEndsWith( - '/views/base.pug', - str_replace('\\', '/', $locator->locate('base.pug', $paths, $extensions)) - ); - self::assertFileExists($locator->locate('first-module', $paths, $extensions)); - self::assertStringEndsWith( - '/mixins/lib1/first-module.pug', - str_replace('\\', '/', $locator->locate('first-module', $paths, $extensions)) - ); - self::assertFileExists($locator->locate('first-module.pug', $paths, $extensions)); - self::assertStringEndsWith( - '/mixins/lib1/first-module.pug', - str_replace('\\', '/', $locator->locate('first-module.pug', $paths, $extensions)) - ); - - self::assertFileExists($locator->locate('../layouts/base', $paths, $extensions)); - self::assertStringEndsWith( - '/layouts/base.pug', - str_replace('\\', '/', $locator->locate('../layouts/base', $paths, $extensions)) - ); - - self::assertFileExists($locator->locate('index', $paths, $extensions)); - self::assertStringEndsWith( - '/views/index.pug', - str_replace('\\', '/', $locator->locate('index', $paths, $extensions)) - ); - - self::assertFileExists($locator->locate('test/index', $paths, $extensions)); - self::assertStringEndsWith( - '/views/test/index.pug', - str_replace('\\', '/', $locator->locate('test/index', $paths, $extensions)) - ); - - self::assertFileExists($locator->locate('first-module', $paths, $extensions)); - self::assertStringEndsWith( - '/mixins/lib1/first-module.pug', - str_replace('\\', '/', $locator->locate('first-module', $paths, $extensions)) - ); - - self::assertFileExists($locator->locate('second-module', $paths, $extensions)); - self::assertStringEndsWith( - '/mixins/lib2/second-module.pug', - str_replace('\\', '/', $locator->locate('second-module', $paths, $extensions)) - ); - - $locator = new FileLocator(); - self::assertSame(__FILE__, $locator->locate(__FILE__, [], [])); - self::assertNull($locator->locate('foo.pug', [], [])); - self::assertNull($locator->locate('foo.pug', [], [])); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/AssignmentListNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/AssignmentListNodeCompilerTest.php deleted file mode 100644 index 1687a51..0000000 --- a/tests/Phug/Compiler/NodeCompiler/AssignmentListNodeCompilerTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to assignment list compiler.' - ); - - $assignmentListCompiler = new AssignmentListNodeCompiler(new Compiler()); - $assignmentListCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/AssignmentNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/AssignmentNodeCompilerTest.php deleted file mode 100644 index 04b9889..0000000 --- a/tests/Phug/Compiler/NodeCompiler/AssignmentNodeCompilerTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @covers \Phug\Compiler\NodeCompiler\ElementNodeCompiler::compileNode - */ - public function testCompile() - { - $this->assertRender( - '', - 'a&attributes(["href" => "#"])' - ); - $this->assertRender( - '', - 'a.foo(class=["bar", "biz"])&attributes(["class" => "bar fiz"])' - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to assignment compiler.' - ); - - $assignmentCompiler = new AssignmentNodeCompiler(new Compiler()); - $assignmentCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/AttributeListCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/AttributeListCompilerTest.php deleted file mode 100644 index 5fb9167..0000000 --- a/tests/Phug/Compiler/NodeCompiler/AttributeListCompilerTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to attribute list compiler.' - ); - - $attributeListCompiler = new AttributeListNodeCompiler(new Compiler()); - $attributeListCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/AttributeNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/AttributeNodeCompilerTest.php deleted file mode 100644 index 7b792a8..0000000 --- a/tests/Phug/Compiler/NodeCompiler/AttributeNodeCompilerTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @covers ::compileName - * @covers ::compileValue - * @covers \Phug\Compiler\NodeCompiler\ElementNodeCompiler::compileNode - */ - public function testCompile() - { - $this->assertRender('', 'input(name="a")'); - $this->assertRender('', 'input((name)="a")'); - $this->assertRender('', 'input("(name)"="a")'); - $this->assertRender('', 'input(name!="")'); - $this->assertRender('', 'input(name)'); - $this->assertRender('', 'input(name="")'); - $this->assertRender([ - '', - ], [ - 'img(', - 'src="foo.$png" ', - 'alt=\'$bar\' ', - 'width=strtoupper("foo.png") ', - 'height=30 ', - 'data-ratio=0.54 ', - 'data-code=0x3f4d)', - ]); - $this->assertRender( - '', - 'img(src!=$image)' - ); - $this->assertRender( - '', - 'a(class=[1,2,3], data-class=[1,2,3])' - ); - } - - /** - * @covers :: - */ - public function testUnescapedAttributes() - { - $this->assertRenderFile( - [ - ''.PHP_EOL, - ], - __DIR__.'/../../../templates/attrs.unescaped.pug', - [ - 'pretty' => ' ', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to attribute compiler.' - ); - - $attributeCompiler = new AttributeNodeCompiler(new Compiler()); - $attributeCompiler->compileNode(new ElementNode()); - } - - /** - * @covers ::compileValue - * @expectedException \Phug\CompilerException - */ - public function testAttributeException() - { - $this->expectMessageToBeThrown( - 'Attribute value can only be a string, a boolean or an expression, '. - 'stdClass given.' - ); - - $attributeCompiler = new AttributeNodeCompiler(new Compiler()); - $node = new AttributeNode(); - $node->setValue(new stdClass()); - $attributeCompiler->compileNode($node); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest.php deleted file mode 100644 index e0d66b1..0000000 --- a/tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @covers ::compileNamedBlock - * @covers \Phug\Compiler\Element\BlockElement:: - */ - public function testBlock() - { - $this->assertCompile( - [ - '
', - '

Foo

', - '
', - ], - [ - "div\n", - " block place\n", - ' p Foo', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to block compiler.' - ); - - $blockCompiler = new BlockNodeCompiler(new Compiler()); - $blockCompiler->compileNode(new ElementNode()); - } - - /** - * @covers \Phug\Compiler::compileBlocks - * @expectedException \Phug\CompilerException - */ - public function testCompileBlocksException() - { - $this->expectMessageToBeThrown( - 'Unexpected block for the name foo' - ); - - require_once __DIR__.'/BlockNodeCompilerTest/TestBlockNodeCompiler.php'; - $compiler = new Compiler([ - 'node_compilers' => [ - BlockNode::class => TestBlockNodeCompiler::class, - ], - ]); - $compiler->compile('block foo'); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest/TestBlockNodeCompiler.php b/tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest/TestBlockNodeCompiler.php deleted file mode 100644 index 015e1b7..0000000 --- a/tests/Phug/Compiler/NodeCompiler/BlockNodeCompilerTest/TestBlockNodeCompiler.php +++ /dev/null @@ -1,19 +0,0 @@ -getCompiler()->getBlocksByName('foo'); - $blocks[] = 'bar'; - - return new BlockElement($this->getCompiler(), 'bar', null, $parent); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/CaseNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/CaseNodeCompilerTest.php deleted file mode 100644 index 9b0198e..0000000 --- a/tests/Phug/Compiler/NodeCompiler/CaseNodeCompilerTest.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @covers \Phug\Compiler\NodeCompiler\WhenNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\AbstractStatementNodeCompiler:: - */ - public function testCompile() - { - $this->assertCompile( - [ - '', - '', - '', - '

Hello

', - '', - '', - '

Bye

', - '', - ], - [ - 'case $foo'."\n", - ' when 0'."\n", - ' when 1'."\n", - ' p Hello'."\n", - ' default'."\n", - ' p Bye', - ] - ); - $this->assertCompile( - [ - '', - '', - '', - '', - '', - '', - '

It\'s this!

', - '', - '', - '

It\'s that!

', - '', - '', - '', - '', - ], - [ - 'doctype html'."\n", - 'html'."\n", - ' body'."\n", - ' - $s = "this"'."\n". - ' case $s'."\n". - ' //- Comment'."\n", - ' when "this"'."\n", - ' p It\'s this!'."\n", - ' when "that"'."\n", - ' p It\'s that!'."\n", - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to case compiler.' - ); - - $caseCompiler = new CaseNodeCompiler(new Compiler()); - $caseCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/CodeNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/CodeNodeCompilerTest.php deleted file mode 100644 index fd97c53..0000000 --- a/tests/Phug/Compiler/NodeCompiler/CodeNodeCompilerTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @covers \Phug\Compiler\AbstractNodeCompiler::getTextChildren - */ - public function testCompile() - { - $this->assertCompile( - '', - '- $foo = 4' - ); - $this->assertCompile( - [ - '', - 'Foo is true', - '
Foo is true
', - '', - 'Foo is false', - '
Foo is false
', - '', - ], - [ - '- if ($foo)'."\n", - ' //- Foo is true'."\n", - ' | Foo is true'."\n", - ' div Foo is true'."\n", - '- else'."\n", - ' //- Foo is false'."\n", - ' | Foo is false'."\n", - ' div Foo is false', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to code compiler.' - ); - - $expressionCompiler = new CodeNodeCompiler(new Compiler()); - $expressionCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/CommentNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/CommentNodeCompilerTest.php deleted file mode 100644 index f14ff89..0000000 --- a/tests/Phug/Compiler/NodeCompiler/CommentNodeCompilerTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ - public function testCompile() - { - $this->assertCompile( - '', - '//Comment' - ); - $this->assertCompile( - '', - '//- Comment' - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to comment compiler.' - ); - - $commentCompiler = new CommentNodeCompiler(new Compiler()); - $commentCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/ConditionalNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/ConditionalNodeCompilerTest.php deleted file mode 100644 index 9d7b650..0000000 --- a/tests/Phug/Compiler/NodeCompiler/ConditionalNodeCompilerTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @covers \Phug\Compiler\NodeCompiler\AbstractStatementNodeCompiler:: - */ - public function testCompile() - { - $this->assertCompile( - [ - ' 50) { ?>', - '

Huge foo

', - ' 20) { ?>', - '

Big foo

', - ' 10) { ?>', - '

Medium foo

', - '', - '

Small foo

', - '', - ], - [ - 'if $foo > 50'."\n", - ' p Huge foo'."\n", - 'else if $foo > 20'."\n", - ' p Big foo'."\n", - 'elseif $foo > 10'."\n", - ' p Medium foo'."\n", - 'else'."\n", - ' p Small foo', - ] - ); - $this->assertCompile( - [ - '', - '

Even foo

', - '', - '

Odd foo

', - '', - ], - [ - 'unless $foo % 1'."\n", - ' p Even foo'."\n", - 'else'."\n", - ' p Odd foo', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to conditional compiler.' - ); - - $conditionalCompiler = new ConditionalNodeCompiler(new Compiler()); - $conditionalCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/DoNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/DoNodeCompilerTest.php deleted file mode 100644 index 646dee3..0000000 --- a/tests/Phug/Compiler/NodeCompiler/DoNodeCompilerTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to do compiler.' - ); - - $doCompiler = new DoNodeCompiler(new Compiler()); - $doCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/DoctypeNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/DoctypeNodeCompilerTest.php deleted file mode 100644 index ffe93dd..0000000 --- a/tests/Phug/Compiler/NodeCompiler/DoctypeNodeCompilerTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ - public function testCompile() - { - $this->assertCompile( - [ - '', - ], - [ - 'doctype html', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to doctype compiler.' - ); - - $doctypeCompiler = new DoctypeNodeCompiler(new Compiler()); - $doctypeCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/DocumentNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/DocumentNodeCompilerTest.php deleted file mode 100644 index 51e20ed..0000000 --- a/tests/Phug/Compiler/NodeCompiler/DocumentNodeCompilerTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ - public function testCompile() - { - $this->assertCompile('', 'html'); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to document compiler.' - ); - - $documentCompiler = new DocumentNodeCompiler(new Compiler()); - $documentCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/EachNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/EachNodeCompilerTest.php deleted file mode 100644 index 67493a1..0000000 --- a/tests/Phug/Compiler/NodeCompiler/EachNodeCompilerTest.php +++ /dev/null @@ -1,225 +0,0 @@ - - * @covers ::compileLoop - * @covers ::getScopeVariablesDump - * @covers ::getScopeVariablesRestore - * @covers ::scopeEachVariables - * @covers \Phug\Compiler\NodeCompiler\AbstractStatementNodeCompiler::wrapStatement - */ - public function testCompile() - { - $this->assertCompile( - [ - '', - '

', - '', - ], - [ - 'each $item in $items'."\n", - ' p?!=$item', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - '', - '', - '

', - '', - '', - '

no items

', - '', - ], - [ - 'each $item in $items'."\n", - ' p?!=$item'."\n", - 'else'."\n", - ' p no items', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - ' $item) { ?>', - '

', - '', - ], - [ - 'each $item, $key in $items'."\n", - ' p?!=$item', - ], - [ - 'scope_each_variables' => false, - ] - ); - } - - /** - * @covers :: - * @covers ::compileLoop - * @covers ::getScopeVariablesDump - * @covers ::getScopeVariablesRestore - * @covers ::scopeEachVariables - * @covers \Phug\Compiler\NodeCompiler\AbstractStatementNodeCompiler::wrapStatement - */ - public function testCompileVariablesScope() - { - $this->assertRender( - [ - '

42

', - '
    ', - '
  • 1
  • ', - '
  • 2
  • ', - '
  • 3
  • ', - '
', - '

42

', - ], - [ - '- $val = 42'."\n", - 'p= $val'."\n", - 'ul'."\n", - ' each $val in [1, 2, 3]'."\n", - ' li= $val'."\n", - 'p= $val', - ] - ); - $this->assertRender( - [ - '

x 42

', - '
    ', - '
  • 0 1
  • ', - '
  • 1 2
  • ', - '
  • 2 3
  • ', - '
', - '

x 42

', - ], - [ - '- $val = 42'."\n", - '- $index = "x"'."\n", - 'p #{$index} #{$val}'."\n", - 'ul'."\n", - ' each $val, $index in [1, 2, 3]'."\n", - ' li #{$index} #{$val}'."\n", - 'p #{$index} #{$val}', - ] - ); - $this->assertRender( - [ - '

42

', - '
    ', - '
  • 1
  • ', - '
  • 2
  • ', - '
  • 3
  • ', - '
', - '

3

', - ], - [ - '- $val = 42'."\n", - 'p= $val'."\n", - 'ul'."\n", - ' each $val in [1, 2, 3]'."\n", - ' li= $val'."\n", - 'p= $val', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertRender( - [ - '

x 42

', - '
    ', - '
  • 0 1
  • ', - '
  • 1 2
  • ', - '
  • 2 3
  • ', - '
', - '

2 3

', - ], - [ - '- $val = 42'."\n", - '- $index = "x"'."\n", - 'p #{$index} #{$val}'."\n", - 'ul'."\n", - ' each $val, $index in [1, 2, 3]'."\n", - ' li #{$index} #{$val}'."\n", - 'p #{$index} #{$val}', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertRender( - [ - '

42

', - '
    ', - '
  • 1
  • ', - '
  • 2
  • ', - '
  • 3
  • ', - '
', - '

42

', - ], - [ - '- $val = 42'."\n", - 'p= $val'."\n", - 'ul'."\n", - ' each $val in [1, 2, 3]'."\n", - ' li= $val'."\n", - 'p= $val', - ], - [ - 'scope_each_variables' => '__anyName', - ] - ); - $this->assertRender( - [ - '

', - '
    ', - '
  • 1
  • ', - '
  • 2
  • ', - '
  • 3
  • ', - '
', - '

', - ], - [ - 'p= $val'."\n", - 'ul'."\n", - ' each $val in [1, 2, 3]'."\n", - ' li= $val'."\n", - 'p= $val', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to each compiler.' - ); - - $eachCompiler = new EachNodeCompiler(new Compiler()); - $eachCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/ElementNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/ElementNodeCompilerTest.php deleted file mode 100644 index 22157af..0000000 --- a/tests/Phug/Compiler/NodeCompiler/ElementNodeCompilerTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ - public function testCompile() - { - $this->assertCompile('
', 'section: input'); - $this->assertCompile('
', 'section'); - $this->assertCompile('
', '#{"section"}'); - $this->assertCompile('
', 'section/'); - } - - /** - * @covers :: - */ - public function testExpansionCompile() - { - $this->assertRender( - '
  • baz
', - "ul\n li.list-item: .foo: #bar baz" - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\DoNode '. - 'given to element compiler.' - ); - - $elementCompiler = new ElementNodeCompiler(new Compiler()); - $elementCompiler->compileNode(new DoNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/ExpressionNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/ExpressionNodeCompilerTest.php deleted file mode 100644 index e6b07bf..0000000 --- a/tests/Phug/Compiler/NodeCompiler/ExpressionNodeCompilerTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ - public function testCompile() - { - $this->assertCompile( - '

', - 'p?!=$foo' - ); - $this->assertCompile( - '

', - 'p=$foo' - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to expression compiler.' - ); - - $expressionCompiler = new ExpressionNodeCompiler(new Compiler()); - $expressionCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/FilterNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/FilterNodeCompilerTest.php deleted file mode 100644 index 40d4ce2..0000000 --- a/tests/Phug/Compiler/NodeCompiler/FilterNodeCompilerTest.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @covers \Phug\Compiler\AbstractNodeCompiler::getTextChildren - */ - public function testCompile() - { - $compiler = new Compiler([ - 'filters' => [ - 'js' => function ($contents) { - return ""; - }, - ], - ]); - self::assertSame( - "', - $compiler->compile( - 'body'."\n". - ' :js'."\n". - ' (function () {'."\n". - ' console.log("Foo");'."\n". - ' })()' - ) - ); - $filter = new FilterNode(); - $filter->setName('js'); - $text1 = new TextNode(); - $text1->setValue('(function () {'); - $text2 = new TextNode(); - $text2->setValue('console.log("Foo");'); - $text3 = new TextNode(); - $text3->setValue('})()'); - $text1->appendChild($text2); - $filter->appendChild($text1); - $filter->appendChild($text3); - self::assertSame( - "', - $compiler->compileNode($filter)->getValue() - ); - //parse - } - - /** - * @covers ::compileText - * @covers :: - * @covers \Phug\Compiler\AbstractNodeCompiler::getTextChildren - */ - public function testLegacyFilters() - { - $compiler = new Compiler([ - 'filters' => [ - 'coffee' => CoffeeScript::class, - ], - ]); - self::assertSame( - '', - $compiler->compile( - 'script'."\n". - ' :coffee'."\n". - ' do ->'."\n". - ' console.log "Foo"' - ) - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testWrongFilterException() - { - $this->expectMessageToBeThrown( - 'Unknown filter j-s.' - ); - - $compiler = new Compiler([ - 'filters' => [ - 'js' => function ($contents) { - return $contents; - }, - ], - ]); - $compiler->compile( - 'body'."\n". - ' :j-s'."\n". - ' (function () {'."\n". - ' console.log("Foo");'."\n". - ' })()' - ); - } - - /** - * @covers :: - */ - public function testFilterOption() - { - $compiler = new Compiler([ - 'filters' => [ - 'foo' => function ($contents, $options) { - return $contents.$options['opt']; - }, - ], - ]); - self::assertSame( - '21', - $compiler->compile( - ':foo(opt=1) 2' - ) - ); - } - - /** - * @covers :: - */ - public function testFilterCompilerArgument() - { - $compiler = new Compiler([ - 'filename' => '/directory/bar.pug', - 'filters' => [ - 'foo' => function ($contents, $options, CompilerInterface $compiler) { - return basename($compiler->getPath()); - }, - ], - ]); - self::assertSame( - 'bar.pug', - $compiler->compile( - ':foo' - ) - ); - } - - /** - * @covers ::compileText - * @expectedException \Phug\CompilerException - */ - public function testFilterChildrenException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\\Formatter\\Element\\DocumentElement in foo filter.' - ); - - $compiler = new Compiler([ - 'on_element' => function (Compiler\Event\ElementEvent $event) { - if ($event->getElement() instanceof TextElement) { - $event->setElement(new DocumentElement()); - } - }, - 'filters' => [ - 'foo' => function ($contents) { - return $contents; - }, - ], - ]); - $compiler->compile( - 'body'."\n". - ' :foo text' - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to filter compiler.' - ); - - $filterCompiler = new FilterNodeCompiler(new Compiler()); - $filterCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/ForNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/ForNodeCompilerTest.php deleted file mode 100644 index 0854b05..0000000 --- a/tests/Phug/Compiler/NodeCompiler/ForNodeCompilerTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @covers \Phug\Compiler\NodeCompiler\EachNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\EachNodeCompiler::compileLoop - * @covers \Phug\Compiler\NodeCompiler\AbstractStatementNodeCompiler::wrapStatement - */ - public function testCompile() - { - $this->assertCompile( - '', - 'for $item in $items', - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - '', - '

', - '', - ], - [ - 'for $item in $items'."\n", - ' //- for each item of items'."\n", - ' p?!=$item', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - '', - '', - '

', - '', - '', - '

no items

', - '', - ], - [ - 'for $item in $items'."\n", - ' p?!=$item'."\n", - 'else'."\n", - ' p no items', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - '', - '', - '

', - '', - '', - '

no items

', - '', - ], - [ - 'for $item in $items'."\n", - ' p?!=$item'."\n", - '//- comments does not count'."\n", - 'else'."\n", - ' p no items', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - ' $item) { ?>', - '

', - '', - ], - [ - 'for $item, $key in $items'."\n", - ' p?!=$item', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - ' $__none) { ?>', - '

', - '', - ], - [ - 'for $key of $items'."\n", - ' p?!=$key', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - ' $item) { ?>', - '

', - '', - ], - [ - 'for $key, $item of $items'."\n", - ' p?!=$item', - ], - [ - 'scope_each_variables' => false, - ] - ); - $this->assertCompile( - [ - '', - '

', - '', - ], - [ - 'for $i = 0; $i < 5; $i++'."\n", - ' p?!=$i', - ], - [ - 'scope_each_variables' => false, - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to for compiler.' - ); - - $forCompiler = new ForNodeCompiler(new Compiler()); - $forCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/ImportNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/ImportNodeCompilerTest.php deleted file mode 100644 index 3bf7420..0000000 --- a/tests/Phug/Compiler/NodeCompiler/ImportNodeCompilerTest.php +++ /dev/null @@ -1,332 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to import compiler.' - ); - - $importCompiler = new ImportNodeCompiler(new Compiler()); - $importCompiler->compileNode(new ElementNode()); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\Element\BlockElement:: - * @covers \Phug\Compiler\NodeCompiler\FilterNodeCompiler::compileNode - */ - public function testInclude() - { - $this->assertCompile( - '
sample
', - 'section: include /inc.pug' - ); - $this->compiler->setOption(['filters', 'upper'], function ($contents) { - return strtoupper($contents); - }); - $this->assertCompile( - '
UPPER
', - 'section: include:upper /lower.txt' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler::reset - * @covers \Phug\Compiler::__clone - * @covers \Phug\Compiler::setLayout - * @covers \Phug\Compiler::getBlocksByName - * @covers \Phug\Compiler\Util\YieldHandlerTrait::setImportNode - * @covers \Phug\Compiler\Util\YieldHandlerTrait::isImportNodeYielded - * @covers \Phug\Compiler::importBlocks - * @covers \Phug\Compiler::compileBlocks - * @covers \Phug\Compiler::compile - * @covers \Phug\Compiler::replaceBlock - * @covers \Phug\Compiler::compileDocument - * @covers \Phug\Compiler::compileFile - * @covers \Phug\Compiler::compileFileIntoElement - * @covers \Phug\Compiler::getPath - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::hasBlockParent - * @covers \Phug\Compiler\Element\BlockElement:: - * @covers \Phug\Compiler\Layout:: - */ - public function testReplaceBlocks() - { - $this->assertCompileFile( - '
Bye
Bye
', - __DIR__.'/../../../templates/replace.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler::reset - * @covers \Phug\Compiler::__clone - * @covers \Phug\Compiler::setLayout - * @covers \Phug\Compiler::getBlocksByName - * @covers \Phug\Compiler\Util\YieldHandlerTrait::setImportNode - * @covers \Phug\Compiler\Util\YieldHandlerTrait::isImportNodeYielded - * @covers \Phug\Compiler::importBlocks - * @covers \Phug\Compiler::compileBlocks - * @covers \Phug\Compiler::compile - * @covers \Phug\Compiler::compileDocument - * @covers \Phug\Compiler::compileFile - * @covers \Phug\Compiler::compileFileIntoElement - * @covers \Phug\Compiler::getPath - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::hasBlockParent - * @covers \Phug\Compiler\Element\BlockElement:: - * @covers \Phug\Compiler\Layout:: - */ - public function testExtends() - { - $this->assertCompileFile( - "
1\nA2\nA
", - __DIR__.'/../../../templates/page.pug' - ); - - $list = &$this->compiler->getBlocksByName('foo'); - self::assertCount(2, $list); - /* @var \Phug\Compiler\Element\BlockElement $copyBlock */ - $copyBlock = clone $list[0]; - self::assertCount(3, $list); - self::assertSame('foo', $copyBlock->getName()); - } - - /** - * @covers :: - * @covers \Phug\Compiler\Util\YieldHandlerTrait::setYieldNode - * @covers \Phug\Compiler\Util\YieldHandlerTrait::unsetYieldNode - * @covers \Phug\Compiler\Util\YieldHandlerTrait::getYieldNode - * @covers \Phug\Compiler\NodeCompiler\YieldNodeCompiler:: - * @covers \Phug\Compiler\Element\BlockElement:: - */ - public function testDoubleInheritance() - { - $this->assertCompile( - [ - 'The message is ""', - ], - [ - '| The message is "'."\n", - 'yield'."\n", - '| "'."\n", - ] - ); - $this->assertRenderFile( - [ - '
', - 'Close', - '
', - '

Alert!

', - '

I\'m an alert!

', - '
', - '
', - ], - __DIR__.'/../../../templates/inheritance.alert-dialog.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler\Element\BlockElement:: - */ - public function testExtendsInInclude() - { - $this->assertCompileFile( - "
1\nA2A
1\nA2A
", - __DIR__.'/../../../templates/inc-page.pug' - ); - } - - /** - * @covers :: - */ - public function testAutoYield() - { - $this->assertRenderFile( - '
switch
img
', - __DIR__.'/../../../templates/auto-yield.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\YieldNodeCompiler:: - */ - public function testNestedYield() - { - $expected = file_get_contents(__DIR__.'/../../../templates/yield-in-sub-include.html'); - - $this->assertCompileFile( - str_replace("\n", '', $expected), - __DIR__.'/../../../templates/yield-in-sub-include.pug' - ); - } - - /** - * @covers :: - */ - public function testMixinsPropagation() - { - $expected = file_get_contents(__DIR__.'/../../../templates/inheritance.extend.mixins.html'); - - $this->assertRenderFile( - preg_replace('/\n\s*/', '', $expected), - __DIR__.'/../../../templates/inheritance.extend.mixins.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\YieldNodeCompiler:: - * @covers \Phug\Compiler\Util\YieldHandlerTrait::getImportNode - * @covers \Phug\Compiler\Util\YieldHandlerTrait::setYieldNode - * @covers \Phug\Compiler\Util\YieldHandlerTrait::unsetYieldNode - */ - public function testYieldInInclude() - { - $this->assertCompileFile( - '
foo

Hello

bar
', - __DIR__.'/../../../templates/inc-yield.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\Element\BlockElement:: - */ - public function testIncludeNoExtension() - { - $this->assertCompileFile( - '

Pug

', - __DIR__.'/../../../templates/inc-no-extension.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\Element\BlockElement:: - */ - public function testIncludeChildren() - { - $this->assertCompileFile( - '
sample

A

B

', - __DIR__.'/../../../templates/inc-children.pug' - ); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\Element\BlockElement:: - */ - public function testIncludeRawText() - { - $this->assertCompileFile( - '
var x = "\n here is some \n new lined text";'."\n
", - __DIR__.'/../../../templates/includes-with-ext-js.pug' - ); - } - - /** - * @covers :: - */ - public function testNestedIncludedMixins() - { - $this->assertRenderFile( - file_get_contents(__DIR__.'/../../../templates/issue26/error-test.html'), - __DIR__.'/../../../templates/issue26/error-test.pug' - ); - } - - /** - * @covers \Phug\Compiler::compileIntoElement - * @expectedException \Phug\CompilerException - */ - public function testCompileIntoElementException() - { - $this->expectMessageToBeThrown( - 'Phug\Parser\Node\DocumentNode '. - 'compiled into a value that does not '. - 'implement ElementInterface: string' - ); - - require_once __DIR__.'/../../TestCompiler.php'; - $compiler = new TestCompiler(); - $compiler->compile('extends layout'); - } - - /** - * @expectedException \Phug\CompilerException - */ - public function testFileNotFoundException() - { - $this->expectMessageToBeThrown( - 'Source file /missing not found' - ); - - $compiler = new Compiler([ - 'paths' => [__DIR__.'/../../../templates'], - ]); - $compiler->compile('include /missing'); - } - - /** - * @covers \Phug\Compiler::resolve - * @covers \Phug\Compiler::getFileContents - */ - public function testNotFoundTemplate() - { - $compiler = new Compiler([ - 'not_found_template' => 'div Page not found', - 'paths' => [__DIR__.'/../../../templates'], - ]); - $php = $compiler->compile(implode("\n", [ - 'p A', - 'include /missing', - 'p B', - ])); - - self::assertSame('

A

Page not found

B

', $php); - } - - /** - * @covers \Phug\Compiler::throwException - * @expectedException \Phug\CompilerException - */ - public function testFileNotFoundInFileException() - { - $base = __DIR__.'/../../../templates'; - $file = realpath($base.DIRECTORY_SEPARATOR.'include-wrong-path.pug'); - $this->expectMessageToBeThrown( - 'Path: '.$file - ); - $compiler = new Compiler([ - 'paths' => [$base], - ]); - $compiler->compileFile($file); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/KeywordNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/KeywordNodeCompilerTest.php deleted file mode 100644 index f3db6b6..0000000 --- a/tests/Phug/Compiler/NodeCompiler/KeywordNodeCompilerTest.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ - public function testCompile() - { - $this->compiler->setOption(['keywords', 'x:form'], function ($args, KeywordElement $keyword, $name) { - return [ - 'begin' => '
'. - '', - 'end' => '
', - ]; - }); - $this->assertRender( - '
'. - ''. - ''. - ''. - '
', - 'section: x:form FA4E23C'."\n". - ' input(name="name" value="Bob")'."\n". - ' input(name="email" value="bob@bob")' - ); - - $this->compiler->setOption(['keywords', 'foobar'], function () { - return 'foobar'; - }); - $this->assertRender( - '
foobar
', - 'div'."\n". - ' div: section: foobar' - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\DoNode '. - 'given to keyword compiler.' - ); - - $elementCompiler = new KeywordNodeCompiler(new Compiler()); - $elementCompiler->compileNode(new DoNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/MixinCallNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/MixinCallNodeCompilerTest.php deleted file mode 100644 index f6033c9..0000000 --- a/tests/Phug/Compiler/NodeCompiler/MixinCallNodeCompilerTest.php +++ /dev/null @@ -1,355 +0,0 @@ - - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileAnonymousBlock - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\NodeCompiler\MixinNodeCompiler:: - */ - public function testCompile() - { - $this->assertRenderFile( - [ - '
', - '
', - '
', - '
', - '
', - '
', - '
', - '
', - '
bar
', - '
append
', - '
', - '
a
', - '
b
', - '
', - '
', - '

1

', - '
', - '
prepend
', - '

footer-foo

', - '

bar

', - '
footer
', - ], - __DIR__.'/../../../templates/mixins-test.pug' - ); - } - - /** - * @group mixins - * @covers :: - */ - public function testCompileNestedMixins() - { - $this->assertRenderFile( - [ - '

1

', - '

2

', - '

2

', - ], - __DIR__.'/../../../templates/nested-mixins-local-init.pug' - ); - $this->assertRenderFile( - [ - '

1

', - '

2

', - '

2

', - ], - __DIR__.'/../../../templates/nested-mixins.pug', - [], - [ - 'text' => '2', - ] - ); - } - - /** - * @group mixins - * @covers :: - */ - public function testCompileVariadicMixin() - { - $this->assertRender( - [ - '

1

', - '2', - '3', - ], - [ - 'mixin variadicMixin($a, ...$b)'."\n", - ' p=$a'."\n", - ' each $c in $b'."\n", - ' i=$c'."\n", - '+variadicMixin(1, 2, 3)', - ] - ); - } - - /** - * @group mixins - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileAnonymousBlock - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\NodeCompiler\MixinNodeCompiler:: - */ - public function testDoubleBlock() - { - $compiler = new Compiler(); - $this->assertRenderFile( - [ - '
HelloHello
', - '
ByeBye
', - ], - __DIR__.'/../../../templates/mixin-double-block.pug' - ); - } - - /** - * @group mixins - * @covers :: - * @covers \Phug\Compiler::compileDocument - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileAnonymousBlock - */ - public function testDynamicMixins() - { - $this->assertRender( - [ - '
bar
', - ], - [ - 'mixin bar'."\n", - ' div bar'."\n", - '+#{$foo}', - ], - [], - [ - 'foo' => 'bar', - ] - ); - $this->setUp(); - $this->assertRender( - [ - '
', - '1#2#3-4Message', - '
', - '
', - '1#2#3-4Message', - '
', - '

42

', - ], - [ - '- $bar = 40'."\n", - 'mixin bar(a, b, ...c)'."\n", - ' - $bar++'."\n", - ' div&attributes($attributes)'."\n", - ' =$a."#".$b."#".implode("-", $c)'."\n", - ' block'."\n", - '+#{$foo}(1, 2, 3, 4).foo(bar="biz")'."\n", - ' em Message'."\n", - '+#{$foo}(1, 2, 3, 4)&attributes(["bar" => "biz" ])'."\n", - ' em Message'."\n", - 'p=$bar', - ], - [], - [ - 'foo' => 'bar', - ] - ); - } - - /** - * @group mixins - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\MixinNodeCompiler:: - */ - public function testOuterNodes() - { - $this->assertRender( - [ - '
', - '

bar

i
', - ], - [ - 'div: mixin bar'."\n", - ' p bar'."\n", - ' block'."\n", - 'footer'."\n", - ' footer: +#{$foo}: span i', - ], - [], - [ - 'foo' => 'bar', - ] - ); - $this->setUp(); - $this->assertRender( - [ - '
', - '1#2#3-4Message', - '
', - '
', - '1#2#3-4Message', - '
', - '

42

', - ], - [ - '- $bar = 40'."\n", - 'mixin bar(a, b, ...c)'."\n", - ' - $bar++'."\n", - ' div&attributes($attributes)'."\n", - ' =$a."#".$b."#".implode("-", $c)'."\n", - ' block'."\n", - '+#{$foo}(1, 2, 3, 4).foo(bar="biz")'."\n", - ' em Message'."\n", - '+#{$foo}(1, 2, 3, 4)&attributes(["bar" => "biz" ])'."\n", - ' em Message'."\n", - 'p=$bar', - ], - [], - [ - 'foo' => 'bar', - ] - ); - } - - /** - * @group mixins - */ - public function testMissingMixin() - { - $code = [ - 'div'."\n", - ' p: +yolo()', - ]; - $exception = null; - - try { - $this->assertRender( - [], - $code, - [ - 'debug' => true, - ] - ); - } catch (\InvalidArgumentException $e) { - ob_end_clean(); - $exception = $e; - } catch (\Exception $e) { - ob_end_clean(); - $exception = $e; - } catch (\Throwable $e) { - ob_end_clean(); - $exception = $e; - } - - self::assertInstanceOf(\InvalidArgumentException::class, $exception); - self::assertSame('Unknown yolo mixin called.', $exception->getMessage()); - - $php = $this->compiler->compile(implode("\n", $code)); - $lines = explode("\n", $php); - $before = implode("\n", array_slice($lines, 0, $exception->getLine())); - $pos = strrpos($before, '// PUG_DEBUG:'); - $after = str_replace('?>', explode('?>', $after)[1]); - } - - /** - * @group mixins - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileAnonymousBlock - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\NodeCompiler\MixinNodeCompiler:: - */ - public function testMixinAttributes() - { - $this->enableJsPhpize(); - $this->assertRenderFile( - preg_replace( - '/(\S)\/>/', - '$1 />', - preg_replace( - '/\n\s*/', - '', - file_get_contents(__DIR__.'/../../../templates/mixin.attrs.html') - ) - ), - __DIR__.'/../../../templates/mixin.attrs.pug' - ); - } - - /** - * @group mixins - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileAnonymousBlock - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler::compileNamedBlock - * @covers \Phug\Compiler\NodeCompiler\MixinNodeCompiler:: - */ - public function testMixinBlocks() - { - $this->enableJsPhpize(); - $this->assertRenderFile( - preg_replace( - '/(\S)\/>/', - '$1 />', - preg_replace( - '/\n\s*/', - '', - file_get_contents(__DIR__.'/../../../templates/mixin.blocks.html') - ) - ), - __DIR__.'/../../../templates/mixin.blocks.pug' - ); - } - - /** - * @group mixins - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to mixin call compiler.' - ); - - $mixinCallCompiler = new MixinCallNodeCompiler(new Compiler()); - $mixinCallCompiler->compileNode(new ElementNode()); - } - - /** - * @group mixins - * @covers :: - * @expectedException \InvalidArgumentException - */ - public function testUnknownMixin() - { - $this->expectMessageToBeThrown( - 'Unknown undef mixin called.' - ); - - $php = (new Compiler([ - 'debug' => true, - ]))->compile('+undef()'); - eval('?>'.$php); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/MixinNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/MixinNodeCompilerTest.php deleted file mode 100644 index be53dbc..0000000 --- a/tests/Phug/Compiler/NodeCompiler/MixinNodeCompilerTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to mixin compiler.' - ); - - $mixinCompiler = new MixinNodeCompiler(new Compiler()); - $mixinCompiler->compileNode(new ElementNode()); - } - - /** - * @group mixins - * @covers :: - */ - public function testRecursion() - { - $this->assertRender( - [ - '
    ', - '
  • 1
  • ', - '
  • ', - '
      ', - '
    • 2
    • ', - '
    • 3
    • ', - '
    ', - '
  • ', - '
      • 4
  • ', - '
', - ], - [ - 'mixin tree($items)'."\n", - ' ul: each $item in $items'."\n", - ' if is_array($item)'."\n", - ' li: +tree($item)'."\n", - ' else'."\n", - ' li=$item'."\n", - '+tree([1, [2, 3], [[4]]])', - ] - ); - } - - /** - * @group mixins - * @covers :: - */ - public function testRecursionWithBlock() - { - $this->assertRender( - [ - 'Hello
    ', - '
  • 1
  • ', - '
  • ', - 'Hello
      ', - '
    • 2
    • ', - '
    • 3
    • ', - '
    ', - '
  • ', - '
  • Hello
    • Hello
      • 4
  • ', - '
', - ], - [ - 'mixin tree($items)'."\n", - ' block'."\n", - ' ul: each $item in $items'."\n", - ' if is_array($item)'."\n", - ' li: +tree($item)'."\n", - ' block'."\n", - ' else'."\n", - ' li=$item'."\n", - '+tree([1, [2, 3], [[4]]])'."\n". - ' | Hello', - ] - ); - } - - /** - * @group mixins - * @covers \Phug\Compiler\NodeCompiler\BlockNodeCompiler ::compileAnonymousBlock - * @expectedException \Phug\CompilerException - */ - public function testAnonymousBlocksOutsideMixin() - { - $this->expectMessageToBeThrown( - 'Anonymous blocks are not allowed unless they are part of a mixin.' - ); - $this->compiler->compile('block'); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/TextNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/TextNodeCompilerTest.php deleted file mode 100644 index 5ed4fa4..0000000 --- a/tests/Phug/Compiler/NodeCompiler/TextNodeCompilerTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - */ - public function testText() - { - $this->assertCompile('Hello', '| Hello'); - $this->assertCompile( - [ - '
',
-                'article'."\n",
-                '  p Name',
-                '
', - ], - [ - 'pre.'."\n", - ' article'."\n", - ' p Name', - ] - ); - $this->assertCompile( - [ - '

article'."\n", - '

Name

'."\n", - '

', - ], - [ - 'p.'."\n", - ' article'."\n", - ' #[p Name]', - ] - ); - $this->assertCompile( - [ - '
    '."\n", - '
  • foo
  • '."\n", - '
  • bar
  • '."\n", - '
  • baz
  • '."\n", - '
', - ], - [ - '
    '."\n", - '
  • foo
  • '."\n", - '
  • bar
  • '."\n", - '
  • baz
  • '."\n", - '
', - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to text compiler.' - ); - - $textCompiler = new TextNodeCompiler(new Compiler()); - $textCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/VariableNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/VariableNodeCompilerTest.php deleted file mode 100644 index 6725ff4..0000000 --- a/tests/Phug/Compiler/NodeCompiler/VariableNodeCompilerTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ - public function testCompile() - { - $this->assertCompile('', '$answer != 42'); - $this->assertCompile( - '', - '$answer ?= $foo' - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testExpressionException() - { - $this->expectMessageToBeThrown( - 'Variable should be followed by exactly 1 expression.' - ); - - $this->assertCompile('', '$answer'); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to variable compiler.' - ); - - $variableCompiler = new VariableNodeCompiler(new Compiler()); - $variableCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/WhenNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/WhenNodeCompilerTest.php deleted file mode 100644 index b27dd57..0000000 --- a/tests/Phug/Compiler/NodeCompiler/WhenNodeCompilerTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to when compiler.' - ); - - $whenCompiler = new WhenNodeCompiler(new Compiler()); - $whenCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/WhileNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/WhileNodeCompilerTest.php deleted file mode 100644 index 1763642..0000000 --- a/tests/Phug/Compiler/NodeCompiler/WhileNodeCompilerTest.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @covers \Phug\Compiler\NodeCompiler\AbstractStatementNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\WhileNodeCompiler:: - */ - public function testCompile() - { - $this->assertCompile( - [ - '', - '

foo

', - ' 20); ?>', - ], - [ - 'do'."\n", - ' p foo'."\n", - 'while $foo > 20', - ] - ); - $this->assertCompile( - [ - ' 20) { ?>', - '

foo

', - '', - ], - [ - 'while $foo > 20'."\n", - ' p foo', - ] - ); - $this->assertCompile( - [ - '', - '
    ', - '', - '', - '
  • ', - '', - '
', - ], - [ - "- var x = 1;\n", - "ul\n", - " while x < 10\n", - " - x++;\n", - " li= x\n", - ] - ); - } - - /** - * @covers :: - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to while compiler.' - ); - - $whileCompiler = new WhileNodeCompiler(new Compiler()); - $whileCompiler->compileNode(new ElementNode()); - } - - /** - * @covers :: - * @covers \Phug\Compiler\NodeCompiler\DoNodeCompiler:: - * @expectedException \Phug\CompilerException - */ - public function testDoAndWhileSeededException() - { - $this->expectMessageToBeThrown( - 'While statement cannot have children and come after a do statement.' - ); - - $compiler = new Compiler(); - $compiler->compile( - 'do'."\n". - ' div A'."\n". - 'while a()'."\n". - ' div B' - ); - } -} diff --git a/tests/Phug/Compiler/NodeCompiler/YieldNodeCompilerTest.php b/tests/Phug/Compiler/NodeCompiler/YieldNodeCompilerTest.php deleted file mode 100644 index 7d95587..0000000 --- a/tests/Phug/Compiler/NodeCompiler/YieldNodeCompilerTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @expectedException \Phug\CompilerException - */ - public function testException() - { - $this->expectMessageToBeThrown( - 'Unexpected Phug\Parser\Node\ElementNode '. - 'given to yield compiler.' - ); - - $blockCompiler = new YieldNodeCompiler(new Compiler()); - $blockCompiler->compileNode(new ElementNode()); - } -} diff --git a/tests/Phug/CompilerModuleTest.php b/tests/Phug/CompilerModuleTest.php deleted file mode 100644 index 584c172..0000000 --- a/tests/Phug/CompilerModuleTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @covers \Phug\Compiler\Event\CompileEvent:: - */ - public function testCompileEvent() - { - $compiler = new Compiler([ - 'on_compile' => function (CompileEvent $event) { - $event->setInput($event->getInput()."\nfooter"); - }, - ]); - - self::assertSame('
', $compiler->compile('header')); - - $compiler = new Compiler([ - 'on_compile' => function (CompileEvent $event) { - $event->setPath(str_replace('include-wrong-path', 'foo-bar', $event->getPath())); - }, - ]); - - $message = ''; - - try { - $compiler->compileFile(__DIR__.'/../templates/include-wrong-path.pug'); - } catch (CompilerException $exception) { - $message = $exception->getMessage(); - } - - self::assertContains('foo-bar.pug', $message); - } - - /** - * @group modules - * @covers :: - * @covers \Phug\Compiler\Event\OutputEvent:: - */ - public function testOutputEvent() - { - $compiler = new Compiler([ - 'on_output' => function (OutputEvent $event) { - $event->setOutput( - preg_replace('/<\\?.*?\\?>/', '', $event->getOutput()). - mb_strlen($event->getCompileEvent()->getInput()) - ); - }, - ]); - - self::assertSame('
14', $compiler->compile('header=message')); - } - - /** - * @group modules - * @covers :: - * @covers \Phug\Compiler\Event\NodeEvent:: - */ - public function testNodeEvent() - { - $compiler = new Compiler([ - 'on_node' => function (NodeEvent $event) { - if (($element = $event->getNode()) instanceof ElementNode) { - /* @var ElementNode $element */ - $element->setName('footer'); - - $event->setNode($element); - } - }, - ]); - - self::assertSame('
', $compiler->compile('header')); - } - - /** - * @group modules - * @covers :: - * @covers \Phug\Compiler\Event\ElementEvent:: - */ - public function testElementEvent() - { - $compiler = new Compiler([ - 'on_element' => function (ElementEvent $event) { - if (($markup = $event->getElement()) instanceof MarkupElement) { - /* @var MarkupElement $markup */ - $markup->setName('footer'); - - $event->setElement($markup); - } - }, - ]); - - self::assertSame('
', $compiler->compile('header')); - } -} diff --git a/tests/Phug/CompilerTest.php b/tests/Phug/CompilerTest.php deleted file mode 100644 index d6a15be..0000000 --- a/tests/Phug/CompilerTest.php +++ /dev/null @@ -1,521 +0,0 @@ - - * @covers ::__construct - */ - public function testGetters() - { - $compiler = new Compiler(); - - self::assertInstanceOf(Formatter::class, $compiler->getFormatter()); - self::assertInstanceOf(Parser::class, $compiler->getParser()); - } - - /** - * @covers ::compileNode - * @covers ::getNamedCompiler - * @covers ::__construct - */ - public function testCompileNode() - { - $compiler = new Compiler(); - - self::assertInstanceOf(Formatter::class, $compiler->getFormatter()); - self::assertInstanceOf(Parser::class, $compiler->getParser()); - - $section = new ElementNode(); - $section->setName('section'); - - /** - * @var MarkupElement $section - */ - $section = $compiler->compileNode($section); - - self::assertInstanceOf(MarkupElement::class, $section); - self::assertSame('section', $section->getName()); - } - - /** - * @covers :: - * @covers \Phug\Compiler\AbstractNodeCompiler::compileParserNode - * @covers \Phug\Compiler\AbstractNodeCompiler:: - * @covers \Phug\Compiler\NodeCompiler\DoctypeNodeCompiler:: - * @covers ::__construct - */ - public function testCompile() - { - // Empty string - $this->assertCompile('', ''); - - // Single tag - $this->assertCompile('', 'html'); - - // Children - $this->assertCompile([ - '', - '', - '', - '', - ], [ - "html\n", - " head\n", - " body\n", - ]); - - // Doctype - $this->assertCompile( - '', - "doctype html\n". - "html\n". - ' input' - ); - $this->compiler->setOption('short_open_tag_fix', false); - $this->assertCompile([ - '', - '', - '', - '', - '', - '', - '', - '', - ], [ - "doctype html\n", - "html: input\n", - "doctype foobar\n", - "html: input\n", - "doctype xml\n", - "html: input\n", - "doctype 1.1\n", - "html: input\n", - ]); - $this->compiler->setOption('short_open_tag_fix', 'auto'); - } - - /** - * @covers \Phug\Compiler\AbstractNodeCompiler:: - */ - public function testGetCompiledChildren() - { - $forCompiler = new Compiler\NodeCompiler\ForNodeCompiler($this->compiler); - $elementNode = new ElementNode(); - $elementNode->setName('section'); - $for = new CodeElement('foreach ($groups as $group)', null, null, [ - new MarkupElement('article'), - $elementNode, - ]); - $compiledChildren = $forCompiler->getCompiledChildren($for, null); - - self::assertSame(1, count($compiledChildren)); - self::assertInstanceOf(MarkupElement::class, $compiledChildren[0]); - /** - * @var MarkupElement $markup - */ - $markup = $compiledChildren[0]; - self::assertSame('section', $markup->getName()); - } - - /** - * @covers ::__construct - * @expectedException \InvalidArgumentException - */ - public function testParserClassException() - { - $this->expectMessageToBeThrown( - 'Passed parser class '. - 'Phug\Parser\Node\ElementNode '. - 'is not a valid '. - 'Phug\Parser' - ); - - new Compiler([ - 'parser_class_name' => ElementNode::class, - ]); - } - - /** - * @covers ::__construct - * @expectedException \InvalidArgumentException - */ - public function testFormatterClassException() - { - $this->expectMessageToBeThrown( - 'Passed formatter class '. - 'Phug\Parser\Node\ElementNode '. - 'is not a valid '. - 'Phug\Formatter' - ); - - new Compiler([ - 'formatter_class_name' => ElementNode::class, - ]); - } - - /** - * @covers ::__construct - * @expectedException \InvalidArgumentException - */ - public function testLocatorClassException() - { - $this->expectMessageToBeThrown( - 'Passed locator class Phug\Parser\Node\ElementNode is not a valid Phug\Compiler\LocatorInterface' - ); - - new Compiler([ - 'locator_class_name' => ElementNode::class, - ]); - } - - /** - * @covers ::setNodeCompiler - * @expectedException \InvalidArgumentException - */ - public function testSetNodeCompilerException() - { - $this->expectMessageToBeThrown( - 'Passed node compiler needs to implement '. - 'Phug\Compiler\NodeCompilerInterface. Phug\Parser\Node\ElementNode given.' - ); - - $compiler = new Compiler(); - $compiler->setNodeCompiler(ElementNode::class, ElementNode::class); - } - - /** - * @covers ::compileNode - * @expectedException \Phug\CompilerException - */ - public function testCompileNodeException() - { - $this->expectMessageToBeThrown( - 'No compiler found able to compile '. - 'Phug\Test\TestNode' - ); - - include_once __DIR__.'/Node/TestNode.php'; - $compiler = new Compiler(); - $compiler->compileNode(new TestNode()); - } - - /** - * @covers ::locate - * @covers ::resolve - * @covers \Phug\Compiler\NodeCompiler\ImportNodeCompiler::compileNode - * @expectedException \Phug\CompilerException - */ - public function testAbsolutePathWithoutPaths() - { - $this->expectMessageToBeThrown( - 'Either the "basedir" or "paths" option is required'. - ' to use includes and extends with "absolute" paths' - ); - - $compiler = new Compiler(); - $compiler->compile('include /foo.pug'); - } - - /** - * @covers ::locate - */ - public function testLocate() - { - $compiler = new Compiler(['paths' => [__DIR__.'/../templates/example-structure/views']]); - - self::assertStringEndsWith('/views/index.pug', str_replace('\\', '/', $compiler->locate('index'))); - self::assertStringEndsWith('/views/index.pug', str_replace('\\', '/', $compiler->locate('index.pug'))); - } - - /** - * @covers ::resolve - */ - public function testResolve() - { - $compiler = new Compiler(['paths' => [__DIR__.'/../templates/example-structure/views']]); - - self::assertStringEndsWith('/views/index.pug', str_replace('\\', '/', $compiler->resolve('index'))); - self::assertStringEndsWith('/views/index.pug', str_replace('\\', '/', $compiler->resolve('index.pug'))); - } - - /** - * @covers ::resolve - * @expectedException \Phug\CompilerException - * @expectedExceptionMessage Source file not-existent not found - */ - public function testResolveNotFoundException() - { - $compiler = new Compiler(['paths' => [__DIR__.'/../templates/example-structure/views']]); - $compiler->resolve('not-existent'); - } - - /** - * @group hooks - * @covers ::compileNode - * @covers ::compile - * @covers ::__construct - * @covers \Phug\Compiler\Event\ElementEvent::getNodeEvent - */ - public function testHooks() - { - $compiler = new Compiler([ - 'on_node' => function (Compiler\Event\NodeEvent $event) { - $node = $event->getNode(); - if ($node instanceof ElementNode) { - $node->setName($node->getName().'b'); - } - }, - 'on_element' => function (Compiler\Event\ElementEvent $event) { - $element = $event->getElement(); - if ($element instanceof MarkupElement) { - $element->setName($element->getName().'c'.$event->getNodeEvent()->getNode()->getName()); - } - }, - ]); - - self::assertSame('', $compiler->compile('a')); - - $compiler = new Compiler([ - 'on_compile' => function (Compiler\Event\CompileEvent $event) { - $event->setInput($event->getInput().' Hello'); - }, - 'on_output' => function (Compiler\Event\OutputEvent $event) { - $event->setOutput('

'.$event->getOutput().'

'); - }, - ]); - - self::assertSame('

Hello

', $compiler->compile('a')); - - $this->enableJsPhpize(); - - $this->assertRender('

Hello

', 'p=foo.bar', [], [ - 'foo' => [ - 'bar' => 'Hello', - ], - ]); - } - - /** - * @covers \Phug\Compiler::dumpFile - * @covers \Phug\Compiler::dump - */ - public function testDump() - { - $dump = $this->compiler->dumpFile(__DIR__.'/../templates/page.pug'); - - self::assertSame(implode("\n", [ - 'Document: document', - ' Markup: section', - ' Text', - ' Text', - ' Text', - ' Text', - ]), $dump); - } - - /** - * @covers ::getModuleBaseClassName - */ - public function testGetModuleBaseClassName() - { - self::assertSame(CompilerModuleInterface::class, (new Compiler())->getModuleBaseClassName()); - } - - /** - * @covers ::hasFilter - * @covers ::getFilter - * @covers ::setFilter - * @covers ::unsetFilter - */ - public function testFilters() - { - $compiler = new Compiler([ - 'filters' => [ - 'a' => 'A', - 'b' => 'B', - ], - 'filter_resolvers' => [ - function ($name) { - return ctype_digit($name) ? $name * 2 : null; - }, - ], - ]); - - self::assertTrue($compiler->hasFilter('a')); - self::assertTrue($compiler->hasFilter('b')); - self::assertFalse($compiler->hasFilter('c')); - self::assertTrue($compiler->hasFilter('1')); - self::assertTrue($compiler->hasFilter('4')); - self::assertSame('A', $compiler->getFilter('a')); - self::assertSame('B', $compiler->getFilter('b')); - self::assertNull($compiler->getFilter('c')); - self::assertSame(42, $compiler->getFilter('21')); - self::assertSame(0, $compiler->getFilter('0')); - - $compiler->setFilter('c', 'C'); - - self::assertTrue($compiler->hasFilter('c')); - self::assertSame('C', $compiler->getFilter('c')); - - $compiler->unsetFilter('c'); - - self::assertFalse($compiler->hasFilter('c')); - self::assertNull($compiler->getFilter('c')); - } - - /** - * @covers ::throwException - * @expectedException \Phug\CompilerException - */ - public function testThrowException() - { - $compiler = new Compiler(); - $compiler->throwException('Test Exception'); - } - - /** - * @covers ::throwException - * @expectedException \Phug\CompilerException - * @expectedExceptionMessage foobar.pug - */ - public function testThrowExceptionFileName() - { - $compiler = new Compiler([ - 'filename' => 'foobar.pug', - ]); - $compiler->throwException('Test Exception'); - } - - /** - * @covers ::assert - */ - public function testAssertSuccess() - { - $compiler = new Compiler(); - self::assertNull($compiler->assert(true, 'Test Exception')); - } - - /** - * @covers ::assert - * @expectedException \Phug\CompilerException - */ - public function testAssertFailure() - { - $compiler = new Compiler(); - $compiler->assert(false, 'Test Exception'); - } - - /** - * @covers ::initializeFormatter - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Passed formatter class stdClass is not a valid Phug\Formatter - */ - public function testInitializeFormatterException() - { - $compiler = new Compiler([ - 'debug' => false, - ]); - $compiler->setOption('debug', true); - $compiler->setOption('formatter_class_name', \stdClass::class); - $compiler->getFormatter(); - } - - /** - * @covers ::initializeFormatter - */ - public function testInitializeFormatter() - { - $compiler = new Compiler([ - 'debug' => false, - ]); - $compiler->setOption('debug', true); - self::assertTrue($compiler->getFormatter()->getFormatInstance()->getOption('debug')); - } - - /** - * @covers ::getFileContents - */ - public function testGetFileContents() - { - $compiler = new Compiler([ - 'get_file_contents' => 'strtolower', - ]); - self::assertSame('test', $compiler->getFileContents('TEST')); - } - - /** - * @covers ::compile - */ - public function testIncludesOption() - { - $compiler = new Compiler(); - $php = $compiler->compileFile(__DIR__.'/../templates/includes-option.pug'); - ob_start(); - eval('?>'.$php); - $html = trim(ob_get_contents()); - ob_end_clean(); - - self::assertSame('My Application', $html); - - $compiler = new Compiler([ - 'includes' => [ - __DIR__.'/../templates/mixins.pug', - ], - ]); - $php = $compiler->compileFile(__DIR__.'/../templates/includes-option.pug'); - ob_start(); - eval('?>'.$php); - $html = trim(ob_get_contents()); - ob_end_clean(); - - self::assertSame('My Application

bar

', $html); - } - - /** - * @covers ::getParentCompiler - * @covers ::setParentCompiler - * @covers ::registerImportPath - * @covers ::getImportPaths - * @covers ::getCurrentImportPaths - */ - public function testGetCurrentImportPaths() - { - $compiler = new Compiler(); - $directory = realpath(__DIR__.'/../templates'); - $path = $directory.DIRECTORY_SEPARATOR.'inc-multi.pug'; - $length = mb_strlen($directory); - - $compiler->compileFile($path); - - $paths = $compiler->getCurrentImportPaths(); - $filteredPaths = array_unique(array_map(function ($path) use ($length) { - return str_replace(DIRECTORY_SEPARATOR, '/', mb_substr($path, $length + 1)); - }, $paths)); - - self::assertSame([ - 'auxiliary/sub-layout.pug', - 'auxiliary/layout.pug', - 'auxiliary/include.nested.pug', - 'inc-children.pug', - 'inc.pug', - 'inc-page.pug', - 'page.pug', - 'layout.pug', - ], $filteredPaths); - self::assertSame($paths, $compiler->getImportPaths()[$path]); - } -} diff --git a/tests/Phug/Node/TestNode.php b/tests/Phug/Node/TestNode.php deleted file mode 100644 index e9982a5..0000000 --- a/tests/Phug/Node/TestNode.php +++ /dev/null @@ -1,9 +0,0 @@ -') - h1 <%= user.title %> \ No newline at end of file diff --git a/tests/templates/auto-yield.pug b/tests/templates/auto-yield.pug deleted file mode 100644 index 509bca1..0000000 --- a/tests/templates/auto-yield.pug +++ /dev/null @@ -1,4 +0,0 @@ -include auxiliary/switch.pug - | switch -include auxiliary/img.pug - | img diff --git a/tests/templates/auxiliary/img.pug b/tests/templates/auxiliary/img.pug deleted file mode 100644 index 64c8c29..0000000 --- a/tests/templates/auxiliary/img.pug +++ /dev/null @@ -1,3 +0,0 @@ -section - div - img diff --git a/tests/templates/auxiliary/include.nested.pug b/tests/templates/auxiliary/include.nested.pug deleted file mode 100644 index e02731c..0000000 --- a/tests/templates/auxiliary/include.nested.pug +++ /dev/null @@ -1,3 +0,0 @@ -p 5 -yield -p 6 diff --git a/tests/templates/auxiliary/include.simple.pug b/tests/templates/auxiliary/include.simple.pug deleted file mode 100644 index 950715c..0000000 --- a/tests/templates/auxiliary/include.simple.pug +++ /dev/null @@ -1,4 +0,0 @@ -p 3 -include include.nested - yield -p 4 diff --git a/tests/templates/auxiliary/layout.pug b/tests/templates/auxiliary/layout.pug deleted file mode 100644 index 7d183b3..0000000 --- a/tests/templates/auxiliary/layout.pug +++ /dev/null @@ -1,6 +0,0 @@ -html - head - title My Application - block head - body - block content \ No newline at end of file diff --git a/tests/templates/auxiliary/sub-layout.pug b/tests/templates/auxiliary/sub-layout.pug deleted file mode 100644 index 5208352..0000000 --- a/tests/templates/auxiliary/sub-layout.pug +++ /dev/null @@ -1,5 +0,0 @@ -extends layout - -block content - include include.nested - include include.nested diff --git a/tests/templates/auxiliary/switch.pug b/tests/templates/auxiliary/switch.pug deleted file mode 100644 index 5cf8e0f..0000000 --- a/tests/templates/auxiliary/switch.pug +++ /dev/null @@ -1,3 +0,0 @@ -case 1 - when 1 - div diff --git a/tests/templates/base.pug b/tests/templates/base.pug deleted file mode 100644 index 5fe421e..0000000 --- a/tests/templates/base.pug +++ /dev/null @@ -1,10 +0,0 @@ -include mixins - -section - +foo - -block article - div bar - -block footer - div footer diff --git a/tests/templates/dialog.pug b/tests/templates/dialog.pug deleted file mode 100644 index 607bdec..0000000 --- a/tests/templates/dialog.pug +++ /dev/null @@ -1,6 +0,0 @@ - -extends window.pug - -block window-content - .dialog - block content diff --git a/tests/templates/example-structure/layouts/base.pug b/tests/templates/example-structure/layouts/base.pug deleted file mode 100644 index 2617339..0000000 --- a/tests/templates/example-structure/layouts/base.pug +++ /dev/null @@ -1,3 +0,0 @@ - -p - block text \ No newline at end of file diff --git a/tests/templates/example-structure/mixins/lib1/first-module.pug b/tests/templates/example-structure/mixins/lib1/first-module.pug deleted file mode 100644 index c2fb598..0000000 --- a/tests/templates/example-structure/mixins/lib1/first-module.pug +++ /dev/null @@ -1,3 +0,0 @@ - -mixin first-module - | From first-module \ No newline at end of file diff --git a/tests/templates/example-structure/mixins/lib2/second-module.pug b/tests/templates/example-structure/mixins/lib2/second-module.pug deleted file mode 100644 index 34eba6f..0000000 --- a/tests/templates/example-structure/mixins/lib2/second-module.pug +++ /dev/null @@ -1,3 +0,0 @@ - -mixin second-module - | From second-module \ No newline at end of file diff --git a/tests/templates/example-structure/views/base.pug b/tests/templates/example-structure/views/base.pug deleted file mode 100644 index 1987379..0000000 --- a/tests/templates/example-structure/views/base.pug +++ /dev/null @@ -1,5 +0,0 @@ - -extends ../layouts/base - -append text - | From views/base.pug \ No newline at end of file diff --git a/tests/templates/example-structure/views/index.pug b/tests/templates/example-structure/views/index.pug deleted file mode 100644 index 8f5c421..0000000 --- a/tests/templates/example-structure/views/index.pug +++ /dev/null @@ -1,5 +0,0 @@ - -extends base - -append text - | From views/index.pug \ No newline at end of file diff --git a/tests/templates/example-structure/views/mixins.pug b/tests/templates/example-structure/views/mixins.pug deleted file mode 100644 index 9c46f6f..0000000 --- a/tests/templates/example-structure/views/mixins.pug +++ /dev/null @@ -1,10 +0,0 @@ - -extends base - -include first-module -include second-module - -append text - +first-module - +second-module - | From views/index.pug \ No newline at end of file diff --git a/tests/templates/example-structure/views/test/index.pug b/tests/templates/example-structure/views/test/index.pug deleted file mode 100644 index 8e4637d..0000000 --- a/tests/templates/example-structure/views/test/index.pug +++ /dev/null @@ -1,5 +0,0 @@ - -extends base - -append text - | From views/test/index.pug \ No newline at end of file diff --git a/tests/templates/inc-children.pug b/tests/templates/inc-children.pug deleted file mode 100644 index 1f8bd9a..0000000 --- a/tests/templates/inc-children.pug +++ /dev/null @@ -1,4 +0,0 @@ -section - include inc.pug - p A - p B diff --git a/tests/templates/inc-multi.pug b/tests/templates/inc-multi.pug deleted file mode 100644 index 93e31b2..0000000 --- a/tests/templates/inc-multi.pug +++ /dev/null @@ -1,7 +0,0 @@ -extends auxiliary/sub-layout - -append head - div - include inc-children - header - include inc-page diff --git a/tests/templates/inc-no-extension.pug b/tests/templates/inc-no-extension.pug deleted file mode 100644 index afa0285..0000000 --- a/tests/templates/inc-no-extension.pug +++ /dev/null @@ -1 +0,0 @@ -include noextension diff --git a/tests/templates/inc-page.pug b/tests/templates/inc-page.pug deleted file mode 100644 index c0e8fcd..0000000 --- a/tests/templates/inc-page.pug +++ /dev/null @@ -1,2 +0,0 @@ -include page.pug -include page.pug diff --git a/tests/templates/inc-yield.pug b/tests/templates/inc-yield.pug deleted file mode 100644 index 2ea9dfe..0000000 --- a/tests/templates/inc-yield.pug +++ /dev/null @@ -1,3 +0,0 @@ -div - include yield.pug - p Hello diff --git a/tests/templates/inc.pug b/tests/templates/inc.pug deleted file mode 100644 index d2fdab7..0000000 --- a/tests/templates/inc.pug +++ /dev/null @@ -1 +0,0 @@ -div sample diff --git a/tests/templates/include-wrong-path.pug b/tests/templates/include-wrong-path.pug deleted file mode 100644 index 1d36096..0000000 --- a/tests/templates/include-wrong-path.pug +++ /dev/null @@ -1 +0,0 @@ -include wrong-path \ No newline at end of file diff --git a/tests/templates/includes-option.pug b/tests/templates/includes-option.pug deleted file mode 100644 index 4e03223..0000000 --- a/tests/templates/includes-option.pug +++ /dev/null @@ -1,4 +0,0 @@ -extends auxiliary/layout - -block content - +bar() diff --git a/tests/templates/includes-with-ext-js.pug b/tests/templates/includes-with-ext-js.pug deleted file mode 100644 index 65bfa8a..0000000 --- a/tests/templates/includes-with-ext-js.pug +++ /dev/null @@ -1,3 +0,0 @@ -pre - code - include javascript-new-lines.js diff --git a/tests/templates/inheritance.alert-dialog.pug b/tests/templates/inheritance.alert-dialog.pug deleted file mode 100644 index 0239455..0000000 --- a/tests/templates/inheritance.alert-dialog.pug +++ /dev/null @@ -1,6 +0,0 @@ - -extends dialog.pug - -block content - h1 Alert! - p I'm an alert! diff --git a/tests/templates/inheritance.extend.mixins.html b/tests/templates/inheritance.extend.mixins.html deleted file mode 100644 index 618e2b1..0000000 --- a/tests/templates/inheritance.extend.mixins.html +++ /dev/null @@ -1,9 +0,0 @@ - - - My Application - - -

The meaning of life

-

Foo bar baz!

- - \ No newline at end of file diff --git a/tests/templates/inheritance.extend.mixins.pug b/tests/templates/inheritance.extend.mixins.pug deleted file mode 100644 index af37913..0000000 --- a/tests/templates/inheritance.extend.mixins.pug +++ /dev/null @@ -1,11 +0,0 @@ - -extends auxiliary/layout.pug - -mixin article($title) - if $title - h1= $title - block - -block content - +article("The meaning of life") - p Foo bar baz! diff --git a/tests/templates/issue26/error-test.html b/tests/templates/issue26/error-test.html deleted file mode 100644 index 789ac3f..0000000 --- a/tests/templates/issue26/error-test.html +++ /dev/null @@ -1 +0,0 @@ -

i am mixin

\ No newline at end of file diff --git a/tests/templates/issue26/error-test.pug b/tests/templates/issue26/error-test.pug deleted file mode 100644 index 0950d97..0000000 --- a/tests/templates/issue26/error-test.pug +++ /dev/null @@ -1,5 +0,0 @@ -extends ./layout.pug -include ./test-mixin.pug - -block body - +test-mixin() diff --git a/tests/templates/issue26/layout.pug b/tests/templates/issue26/layout.pug deleted file mode 100644 index 1a3f848..0000000 --- a/tests/templates/issue26/layout.pug +++ /dev/null @@ -1,5 +0,0 @@ -doctype html - -html - body - block body diff --git a/tests/templates/issue26/test-mixin.pug b/tests/templates/issue26/test-mixin.pug deleted file mode 100644 index c07abf4..0000000 --- a/tests/templates/issue26/test-mixin.pug +++ /dev/null @@ -1,2 +0,0 @@ -mixin test-mixin() - h1 i am mixin diff --git a/tests/templates/javascript-new-lines.js b/tests/templates/javascript-new-lines.js deleted file mode 100644 index 6893341..0000000 --- a/tests/templates/javascript-new-lines.js +++ /dev/null @@ -1 +0,0 @@ -var x = "\n here is some \n new lined text"; diff --git a/tests/templates/layout.pug b/tests/templates/layout.pug deleted file mode 100644 index a5c3561..0000000 --- a/tests/templates/layout.pug +++ /dev/null @@ -1,5 +0,0 @@ -section - block foo - | 1 - block foo - | 2 diff --git a/tests/templates/lower.txt b/tests/templates/lower.txt deleted file mode 100644 index 941342d..0000000 --- a/tests/templates/lower.txt +++ /dev/null @@ -1 +0,0 @@ -upper \ No newline at end of file diff --git a/tests/templates/mixin-double-block.pug b/tests/templates/mixin-double-block.pug deleted file mode 100644 index 43374cc..0000000 --- a/tests/templates/mixin-double-block.pug +++ /dev/null @@ -1,15 +0,0 @@ -mixin yop(isYup) - if $isYup - header - block - block - else - footer - block - block - -+yop(true) - | Hello - -+yop(false) - | Bye diff --git a/tests/templates/mixin.attrs.html b/tests/templates/mixin.attrs.html deleted file mode 100644 index 2f2e0ef..0000000 --- a/tests/templates/mixin.attrs.html +++ /dev/null @@ -1,32 +0,0 @@ - -
Hello World -
-
-

Section 1

-

Some important content.

-
-
-

Section 2

-

Even more important content.

- -
-
-
-

Section 3

-

Last content.

- -
-
-
-

Some final words.

-
-
-
- -
-
work
-
-

1

-

2

-

3

-

4

\ No newline at end of file diff --git a/tests/templates/mixin.attrs.pug b/tests/templates/mixin.attrs.pug deleted file mode 100644 index 82a46ff..0000000 --- a/tests/templates/mixin.attrs.pug +++ /dev/null @@ -1,59 +0,0 @@ -mixin centered(title) - div.centered(id=attributes.id) - - if (title) - h1(class=attributes.class)= title - block - - if (attributes.href) - .footer - a(href=attributes.href) Back - -mixin main(title) - div.stretch - +centered(title).highlight&attributes(attributes) - block - -mixin bottom - div.bottom&attributes(attributes) - block - -body - +centered#First Hello World - +centered('Section 1')#Second - p Some important content. - +centered('Section 2')#Third.foo(href='menu.html', class='bar') - p Even more important content. - +main('Section 3')(href='#') - p Last content. - +bottom.foo(class='bar', name='end', id='Last', data-attr='baz') - p Some final words. - +bottom(class=['class1', 'class2']) - -mixin foo - div.thing(attr1='foo', attr2='bar')&attributes(attributes) - -- var val = '' -- var classes = ['foo', 'bar'] -+foo(attr3='baz' data-foo=val data-bar!=val class=classes).thunk - -//- Regression test for #1424 -mixin work_filmstrip_item(work) - div&attributes(attributes)= work -+work_filmstrip_item('work')("data-profile"='profile', "data-creator-name"='name') - -mixin my-mixin(arg1, arg2, arg3, arg4) - p= arg1 - p= arg2 - p= arg3 - p= arg4 - -+foo( - attr3="qux" - class="baz" -) - -+my-mixin( -'1', - '2', - '3', - '4' -) diff --git a/tests/templates/mixin.blocks.html b/tests/templates/mixin.blocks.html deleted file mode 100644 index def5c6f..0000000 --- a/tests/templates/mixin.blocks.html +++ /dev/null @@ -1,34 +0,0 @@ - - -
- - - -
- - - - -
- - - -
- - - - -
- -
- - -
-
-

one

-

two

-

three

-
-
-
123 -
\ No newline at end of file diff --git a/tests/templates/mixin.blocks.pug b/tests/templates/mixin.blocks.pug deleted file mode 100644 index 30c9990..0000000 --- a/tests/templates/mixin.blocks.pug +++ /dev/null @@ -1,44 +0,0 @@ - - -mixin form(method, action) - form(method=method, action=action) - - var csrf_token_from_somewhere = 'hey' - input(type='hidden', name='_csrf', value=csrf_token_from_somewhere) - block - -html - body - +form('GET', '/search') - input(type='text', name='query', placeholder='Search') - input(type='submit', value='Search') - -html - body - +form('POST', '/search') - input(type='text', name='query', placeholder='Search') - input(type='submit', value='Search') - -html - body - +form('POST', '/search') - -mixin bar() - #bar - block - -mixin foo() - #foo - +bar - block - -+foo - p one - p two - p three - - -mixin baz - #baz - block - -+baz()= '123' \ No newline at end of file diff --git a/tests/templates/mixins-test.pug b/tests/templates/mixins-test.pug deleted file mode 100644 index 36c816d..0000000 --- a/tests/templates/mixins-test.pug +++ /dev/null @@ -1,17 +0,0 @@ -extends base - -include mixins - -append article - article append - +foo("a", "b") - h1 1 - -prepend footer - mixin foo() - p footer-foo - article prepend - +foo()(do="not care") - h2 2 - +bar().biz - h3 3 diff --git a/tests/templates/mixins.pug b/tests/templates/mixins.pug deleted file mode 100644 index b222a10..0000000 --- a/tests/templates/mixins.pug +++ /dev/null @@ -1,9 +0,0 @@ -mixin foo(a, b) - .ab - .a=$a - .b=$b - div - block - -mixin bar() - p&attributes($attributes) bar diff --git a/tests/templates/nested-mixins-local-init.pug b/tests/templates/nested-mixins-local-init.pug deleted file mode 100644 index 11b023f..0000000 --- a/tests/templates/nested-mixins-local-init.pug +++ /dev/null @@ -1,8 +0,0 @@ -- $text = '2' -mixin paragraph($text) - p= $text - block - -+paragraph('1') - +paragraph($text) -+paragraph($text) diff --git a/tests/templates/nested-mixins.html b/tests/templates/nested-mixins.html deleted file mode 100644 index e69de29..0000000 diff --git a/tests/templates/nested-mixins.pug b/tests/templates/nested-mixins.pug deleted file mode 100644 index cd2e59f..0000000 --- a/tests/templates/nested-mixins.pug +++ /dev/null @@ -1,7 +0,0 @@ -mixin paragraph($text) - p= $text - block - -+paragraph('1') - +paragraph($text) -+paragraph($text) diff --git a/tests/templates/noextension b/tests/templates/noextension deleted file mode 100644 index 2594c01..0000000 --- a/tests/templates/noextension +++ /dev/null @@ -1 +0,0 @@ -p Pug diff --git a/tests/templates/page.pug b/tests/templates/page.pug deleted file mode 100644 index ddb9cf9..0000000 --- a/tests/templates/page.pug +++ /dev/null @@ -1,4 +0,0 @@ -extends layout - -append foo - | A diff --git a/tests/templates/replace.pug b/tests/templates/replace.pug deleted file mode 100644 index d606864..0000000 --- a/tests/templates/replace.pug +++ /dev/null @@ -1,4 +0,0 @@ -extends layout - -block foo - div Bye diff --git a/tests/templates/window.pug b/tests/templates/window.pug deleted file mode 100644 index 7ab7132..0000000 --- a/tests/templates/window.pug +++ /dev/null @@ -1,4 +0,0 @@ - -.window - a(href='#').close Close - block window-content \ No newline at end of file diff --git a/tests/templates/yield-in-sub-include.html b/tests/templates/yield-in-sub-include.html deleted file mode 100644 index af4d93d..0000000 --- a/tests/templates/yield-in-sub-include.html +++ /dev/null @@ -1,7 +0,0 @@ -

1

-

3

-

5

-

Block

-

6

-

4

-

2

diff --git a/tests/templates/yield-in-sub-include.pug b/tests/templates/yield-in-sub-include.pug deleted file mode 100644 index fb60627..0000000 --- a/tests/templates/yield-in-sub-include.pug +++ /dev/null @@ -1,4 +0,0 @@ -p 1 -include auxiliary/include.simple - p Block -p 2 diff --git a/tests/templates/yield.pug b/tests/templates/yield.pug deleted file mode 100644 index 1d6d0d6..0000000 --- a/tests/templates/yield.pug +++ /dev/null @@ -1,3 +0,0 @@ -| foo -yield -| bar