Started fixing tests for the TocGenerator
Этот коммит содержится в:
родитель
aa158141ea
Коммит
5968cfef3e
10
.idea/toc.iml
сгенерированный
10
.idea/toc.iml
сгенерированный
@ -4,5 +4,15 @@
|
|||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="PHP">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file:///usr/bin/composer/phpunit" />
|
||||||
|
</CLASSES>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file:///usr/bin/composer/phpunit" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
2
.idea/vcs.xml
сгенерированный
2
.idea/vcs.xml
сгенерированный
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -28,7 +28,6 @@
|
|||||||
"knplabs/knp-menu": "~2.0"
|
"knplabs/knp-menu": "~2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"twig/twig": "~1.13",
|
"twig/twig": "~1.13"
|
||||||
"phpunit/phpunit": "~4.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
806
composer.lock
сгенерированный
806
composer.lock
сгенерированный
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "adfeb8aba6a2ded99b1e8b37508b4145",
|
"hash": "01914fa61e59dbe4c7c3d1772643be14",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "cocur/slugify",
|
"name": "cocur/slugify",
|
||||||
@ -175,809 +175,18 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
|
||||||
"name": "doctrine/instantiator",
|
|
||||||
"version": "1.0.4",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/doctrine/instantiator.git",
|
|
||||||
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
|
|
||||||
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3,<8.0-DEV"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"athletic/athletic": "~0.1.8",
|
|
||||||
"ext-pdo": "*",
|
|
||||||
"ext-phar": "*",
|
|
||||||
"phpunit/phpunit": "~4.0",
|
|
||||||
"squizlabs/php_codesniffer": "2.0.*@ALPHA"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Doctrine\\Instantiator\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Marco Pivetta",
|
|
||||||
"email": "ocramius@gmail.com",
|
|
||||||
"homepage": "http://ocramius.github.com/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
|
|
||||||
"homepage": "https://github.com/doctrine/instantiator",
|
|
||||||
"keywords": [
|
|
||||||
"constructor",
|
|
||||||
"instantiate"
|
|
||||||
],
|
|
||||||
"time": "2014-10-13 12:58:55"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/php-code-coverage",
|
|
||||||
"version": "2.0.14",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
|
||||||
"reference": "ca158276c1200cc27f5409a5e338486bc0b4fc94"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca158276c1200cc27f5409a5e338486bc0b4fc94",
|
|
||||||
"reference": "ca158276c1200cc27f5409a5e338486bc0b4fc94",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3",
|
|
||||||
"phpunit/php-file-iterator": "~1.3",
|
|
||||||
"phpunit/php-text-template": "~1.2",
|
|
||||||
"phpunit/php-token-stream": "~1.3",
|
|
||||||
"sebastian/environment": "~1.0",
|
|
||||||
"sebastian/version": "~1.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"ext-xdebug": ">=2.1.4",
|
|
||||||
"phpunit/phpunit": "~4.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-dom": "*",
|
|
||||||
"ext-xdebug": ">=2.2.1",
|
|
||||||
"ext-xmlwriter": "*"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"include-path": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sb@sebastian-bergmann.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
|
|
||||||
"keywords": [
|
|
||||||
"coverage",
|
|
||||||
"testing",
|
|
||||||
"xunit"
|
|
||||||
],
|
|
||||||
"time": "2014-12-26 13:28:33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/php-file-iterator",
|
|
||||||
"version": "1.3.4",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
|
||||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
|
|
||||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"File/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"include-path": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sb@sebastian-bergmann.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
|
|
||||||
"keywords": [
|
|
||||||
"filesystem",
|
|
||||||
"iterator"
|
|
||||||
],
|
|
||||||
"time": "2013-10-10 15:34:57"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/php-text-template",
|
|
||||||
"version": "1.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
|
||||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
|
||||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"Text/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"include-path": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sb@sebastian-bergmann.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Simple template engine.",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
|
|
||||||
"keywords": [
|
|
||||||
"template"
|
|
||||||
],
|
|
||||||
"time": "2014-01-30 17:20:04"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/php-timer",
|
|
||||||
"version": "1.0.5",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
|
||||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
|
||||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"PHP/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"include-path": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sb@sebastian-bergmann.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Utility class for timing",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/php-timer/",
|
|
||||||
"keywords": [
|
|
||||||
"timer"
|
|
||||||
],
|
|
||||||
"time": "2013-08-02 07:42:54"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/php-token-stream",
|
|
||||||
"version": "1.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
|
||||||
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
|
|
||||||
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-tokenizer": "*",
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.2"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.3-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Wrapper around PHP's tokenizer extension.",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
|
|
||||||
"keywords": [
|
|
||||||
"tokenizer"
|
|
||||||
],
|
|
||||||
"time": "2014-08-31 06:12:13"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/phpunit",
|
|
||||||
"version": "4.4.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
|
||||||
"reference": "6a5e49a86ce5e33b8d0657abe145057fc513543a"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6a5e49a86ce5e33b8d0657abe145057fc513543a",
|
|
||||||
"reference": "6a5e49a86ce5e33b8d0657abe145057fc513543a",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-dom": "*",
|
|
||||||
"ext-json": "*",
|
|
||||||
"ext-pcre": "*",
|
|
||||||
"ext-reflection": "*",
|
|
||||||
"ext-spl": "*",
|
|
||||||
"php": ">=5.3.3",
|
|
||||||
"phpunit/php-code-coverage": "~2.0",
|
|
||||||
"phpunit/php-file-iterator": "~1.3.2",
|
|
||||||
"phpunit/php-text-template": "~1.2",
|
|
||||||
"phpunit/php-timer": "~1.0.2",
|
|
||||||
"phpunit/phpunit-mock-objects": "~2.3",
|
|
||||||
"sebastian/comparator": "~1.0",
|
|
||||||
"sebastian/diff": "~1.1",
|
|
||||||
"sebastian/environment": "~1.1",
|
|
||||||
"sebastian/exporter": "~1.0",
|
|
||||||
"sebastian/global-state": "~1.0",
|
|
||||||
"sebastian/version": "~1.0",
|
|
||||||
"symfony/yaml": "~2.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"phpunit/php-invoker": "~1.1"
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"phpunit"
|
|
||||||
],
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "4.4.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "The PHP Unit Testing framework.",
|
|
||||||
"homepage": "https://phpunit.de/",
|
|
||||||
"keywords": [
|
|
||||||
"phpunit",
|
|
||||||
"testing",
|
|
||||||
"xunit"
|
|
||||||
],
|
|
||||||
"time": "2014-12-28 07:57:05"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpunit/phpunit-mock-objects",
|
|
||||||
"version": "2.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
|
||||||
"reference": "c63d2367247365f688544f0d500af90a11a44c65"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65",
|
|
||||||
"reference": "c63d2367247365f688544f0d500af90a11a44c65",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"doctrine/instantiator": "~1.0,>=1.0.1",
|
|
||||||
"php": ">=5.3.3",
|
|
||||||
"phpunit/php-text-template": "~1.2"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.3"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-soap": "*"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.3.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sb@sebastian-bergmann.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Mock Object library for PHPUnit",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
|
|
||||||
"keywords": [
|
|
||||||
"mock",
|
|
||||||
"xunit"
|
|
||||||
],
|
|
||||||
"time": "2014-10-03 05:12:11"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sebastian/comparator",
|
|
||||||
"version": "1.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
|
||||||
"reference": "c484a80f97573ab934e37826dba0135a3301b26a"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/c484a80f97573ab934e37826dba0135a3301b26a",
|
|
||||||
"reference": "c484a80f97573ab934e37826dba0135a3301b26a",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3",
|
|
||||||
"sebastian/diff": "~1.1",
|
|
||||||
"sebastian/exporter": "~1.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.1"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.1.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jeff Welch",
|
|
||||||
"email": "whatthejeff@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Volker Dusch",
|
|
||||||
"email": "github@wallbash.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Bernhard Schussek",
|
|
||||||
"email": "bschussek@2bepublished.at"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Provides the functionality to compare PHP values for equality",
|
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/comparator",
|
|
||||||
"keywords": [
|
|
||||||
"comparator",
|
|
||||||
"compare",
|
|
||||||
"equality"
|
|
||||||
],
|
|
||||||
"time": "2014-11-16 21:32:38"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sebastian/diff",
|
|
||||||
"version": "1.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
|
||||||
"reference": "5843509fed39dee4b356a306401e9dd1a931fec7"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7",
|
|
||||||
"reference": "5843509fed39dee4b356a306401e9dd1a931fec7",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.2"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.2-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Kore Nordmann",
|
|
||||||
"email": "mail@kore-nordmann.de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Diff implementation",
|
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/diff",
|
|
||||||
"keywords": [
|
|
||||||
"diff"
|
|
||||||
],
|
|
||||||
"time": "2014-08-15 10:29:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sebastian/environment",
|
|
||||||
"version": "1.2.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
|
||||||
"reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e6c71d918088c251b181ba8b3088af4ac336dd7",
|
|
||||||
"reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.3"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.2.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Provides functionality to handle HHVM/PHP environments",
|
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/environment",
|
|
||||||
"keywords": [
|
|
||||||
"Xdebug",
|
|
||||||
"environment",
|
|
||||||
"hhvm"
|
|
||||||
],
|
|
||||||
"time": "2014-10-25 08:00:45"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sebastian/exporter",
|
|
||||||
"version": "1.0.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
|
||||||
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
|
|
||||||
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jeff Welch",
|
|
||||||
"email": "whatthejeff@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Volker Dusch",
|
|
||||||
"email": "github@wallbash.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Bernhard Schussek",
|
|
||||||
"email": "bschussek@2bepublished.at"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Adam Harvey",
|
|
||||||
"email": "aharvey@php.net"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Provides the functionality to export PHP variables for visualization",
|
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/exporter",
|
|
||||||
"keywords": [
|
|
||||||
"export",
|
|
||||||
"exporter"
|
|
||||||
],
|
|
||||||
"time": "2014-09-10 00:51:36"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sebastian/global-state",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/global-state.git",
|
|
||||||
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
|
|
||||||
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.2"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-uopz": "*"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Snapshotting of global state",
|
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/global-state",
|
|
||||||
"keywords": [
|
|
||||||
"global state"
|
|
||||||
],
|
|
||||||
"time": "2014-10-06 09:23:50"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sebastian/version",
|
|
||||||
"version": "1.0.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sebastianbergmann/version.git",
|
|
||||||
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
|
|
||||||
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sebastian@phpunit.de",
|
|
||||||
"role": "lead"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
|
||||||
"homepage": "https://github.com/sebastianbergmann/version",
|
|
||||||
"time": "2014-03-07 15:35:33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/yaml",
|
|
||||||
"version": "v2.6.1",
|
|
||||||
"target-dir": "Symfony/Component/Yaml",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/Yaml.git",
|
|
||||||
"reference": "3346fc090a3eb6b53d408db2903b241af51dcb20"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/3346fc090a3eb6b53d408db2903b241af51dcb20",
|
|
||||||
"reference": "3346fc090a3eb6b53d408db2903b241af51dcb20",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.6-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Symfony\\Component\\Yaml\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "http://symfony.com/contributors"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony Yaml Component",
|
|
||||||
"homepage": "http://symfony.com",
|
|
||||||
"time": "2014-12-02 20:19:20"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v1.16.3",
|
"version": "v1.17.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "6dc11a1e8ecfc30e2c68aaeb218148409d8e68af"
|
"reference": "2493970fa4d587eca73f77e6d8bd48a8bdd4c608"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/6dc11a1e8ecfc30e2c68aaeb218148409d8e68af",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/2493970fa4d587eca73f77e6d8bd48a8bdd4c608",
|
||||||
"reference": "6dc11a1e8ecfc30e2c68aaeb218148409d8e68af",
|
"reference": "2493970fa4d587eca73f77e6d8bd48a8bdd4c608",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -986,7 +195,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "1.16-dev"
|
"dev-master": "1.17-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -1021,13 +230,14 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"templating"
|
"templating"
|
||||||
],
|
],
|
||||||
"time": "2014-12-25 19:58:19"
|
"time": "2015-01-14 10:15:49"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": ">=5.4"
|
"php": ">=5.4"
|
||||||
},
|
},
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
|
|
||||||
namespace TOC;
|
namespace TOC;
|
||||||
|
|
||||||
|
use Knp\Menu\ItemInterface;
|
||||||
|
use Knp\Menu\Matcher\Matcher;
|
||||||
use Knp\Menu\MenuFactory;
|
use Knp\Menu\MenuFactory;
|
||||||
|
use Knp\Menu\Renderer\ListRenderer;
|
||||||
|
use Knp\Menu\Renderer\RendererInterface;
|
||||||
use Sunra\PhpSimple\HtmlDomParser;
|
use Sunra\PhpSimple\HtmlDomParser;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
@ -47,18 +51,16 @@ class TocGenerator
|
|||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Link Items
|
* Get Menu
|
||||||
*
|
*
|
||||||
* Returns a multi-level associative array of items
|
* Returns a KNP Menu object, which can be traversed or rendered
|
||||||
*
|
*
|
||||||
* @TODO: TEST THIS OUT >> And then refactor the getHtmlItems method to use the built-in KNP List library to do so...
|
* @param string $markup Content to get items fro $this->getItems($markup, $topLevel, $depth)m
|
||||||
*
|
|
||||||
* @param string $markup Content to get items from
|
|
||||||
* @param int $topLevel Top Header (1 through 6)
|
* @param int $topLevel Top Header (1 through 6)
|
||||||
* @param int $depth Depth (1 through 6)
|
* @param int $depth Depth (1 through 6)
|
||||||
* @return \Traversable Menu items
|
* @return ItemInterface KNP Menu
|
||||||
*/
|
*/
|
||||||
public function getItems($markup, $topLevel = 1, $depth = 6)
|
public function getMenu($markup, $topLevel = 1, $depth = 6)
|
||||||
{
|
{
|
||||||
// Setup an empty menu object
|
// Setup an empty menu object
|
||||||
$menu = $this->menuFactory->createItem('TOC');
|
$menu = $this->menuFactory->createItem('TOC');
|
||||||
@ -94,9 +96,6 @@ class TocGenerator
|
|||||||
$tagName = $element->tag;
|
$tagName = $element->tag;
|
||||||
$level = array_search(strtolower($tagName), $tagsToMatch) + 1;
|
$level = array_search(strtolower($tagName), $tagsToMatch) + 1;
|
||||||
|
|
||||||
// TEST DEBUG
|
|
||||||
var_dump($element->plaintext . '; ' . $tagName . ' is level ' . $level . ' and lastLevel is ' . $lastElem->getLevel());
|
|
||||||
|
|
||||||
// Determine parent item which to add child
|
// Determine parent item which to add child
|
||||||
if ($level == 0) {
|
if ($level == 0) {
|
||||||
$parent = $menu;
|
$parent = $menu;
|
||||||
@ -128,25 +127,22 @@ class TocGenerator
|
|||||||
/**
|
/**
|
||||||
* Get HTML Links in list form
|
* Get HTML Links in list form
|
||||||
*
|
*
|
||||||
* @param string $markup Content to get items from
|
* @param string $markup Content to get items from
|
||||||
* @param int $topLevel Top Header (1 through 6)
|
* @param int $topLevel Top Header (1 through 6)
|
||||||
* @param int $depth Depth (1 through 6)
|
* @param int $depth Depth (1 through 6)
|
||||||
* @return string HTML <LI> items
|
* @param RendererInterface $renderer
|
||||||
|
* @return string HTML <LI> items
|
||||||
*/
|
*/
|
||||||
public function getHtmlItems($markup, $topLevel = 1, $depth = 6, $titleTemplate = 'Go to %s')
|
public function getHtmlMenu($markup, $topLevel = 1, $depth = 6, RendererInterface $renderer = null)
|
||||||
{
|
{
|
||||||
$arr = [];
|
if ( ! $renderer) {
|
||||||
|
$renderer = new ListRenderer(new Matcher(), [
|
||||||
foreach ($this->getItems($markup, $topLevel, $depth) as $anchor => $displayText) {
|
'currentClass' => 'active',
|
||||||
$arr[] = sprintf(
|
'ancestorClass' => 'active_ancestor'
|
||||||
"<li><a title='%s' href='#%s'>%s</a></li>",
|
]);
|
||||||
sprintf($titleTemplate, $displayText),
|
|
||||||
$anchor,
|
|
||||||
$displayText
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode('', $arr);
|
return $renderer->render($this->getMenu($markup, $topLevel, $depth));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ class TocTwigExtension extends Twig_Extension
|
|||||||
|
|
||||||
$functions[] = new \Twig_SimpleFunction('toc', function($markup, $top = 1, $depth = 2, $titleTemplate = null) {
|
$functions[] = new \Twig_SimpleFunction('toc', function($markup, $top = 1, $depth = 2, $titleTemplate = null) {
|
||||||
return ($titleTemplate)
|
return ($titleTemplate)
|
||||||
? $this->generator->getHtmlItems($markup, $top, $depth, $titleTemplate)
|
? $this->generator->getHtmlMenu($markup, $top, $depth, $titleTemplate)
|
||||||
: $this->generator->getHtmlItems($markup, $top, $depth);
|
: $this->generator->getHtmlMenu($markup, $top, $depth);
|
||||||
}, ['is_safe' => ['html']]);
|
}, ['is_safe' => ['html']]);
|
||||||
|
|
||||||
// ~~~
|
// ~~~
|
||||||
|
|
||||||
$functions[] = new \Twig_SimpleFunction('toc_items', function($markup, $top = 1, $depth = 2) {
|
$functions[] = new \Twig_SimpleFunction('toc_items', function($markup, $top = 1, $depth = 2) {
|
||||||
return $this->generator->getItems($markup, $top, $depth);
|
return $this->generator->getMenu($markup, $top, $depth);
|
||||||
});
|
});
|
||||||
|
|
||||||
return $functions;
|
return $functions;
|
||||||
@ -82,4 +82,4 @@ class TocTwigExtension extends Twig_Extension
|
|||||||
{
|
{
|
||||||
return 'toc';
|
return 'toc';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,15 @@
|
|||||||
* Time: 12:39 PM
|
* Time: 12:39 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Knp\Menu\Renderer\ListRenderer;
|
||||||
use TOC\TocGenerator;
|
use TOC\TocGenerator;
|
||||||
|
|
||||||
class TocGeneratorTest extends PHPUnit_Framework_TestCase
|
/**
|
||||||
|
* Class TocGeneratorTest
|
||||||
|
*
|
||||||
|
* @author Casey McLaughlin <caseyamcl@gmail.com>
|
||||||
|
*/
|
||||||
|
class TocGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testInstantiateSucceeds()
|
public function testInstantiateSucceeds()
|
||||||
{
|
{
|
||||||
@ -18,72 +24,103 @@ class TocGeneratorTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
|
public function testGetItemsTraversesLevelsCorrectly()
|
||||||
|
{
|
||||||
|
$obj = new TocGenerator();
|
||||||
|
|
||||||
|
$html = "
|
||||||
|
<h1 id='a'>A-Header</h1><p>Foobar</p>
|
||||||
|
<h2 id='b'>B-Header</h2>
|
||||||
|
<h2 id='c'>C-Header</h2>
|
||||||
|
<h3 id='d'>D-Header</h3>
|
||||||
|
<h4 id='e'>E-Header</h4>
|
||||||
|
<h2 id='f'>F-Header</h2>
|
||||||
|
<h5 id='g'>G-Header</h5>
|
||||||
|
<h1 id='h'>H-Header</h1><div>Hi</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
$fixture = array_filter(array_map('trim', file(__DIR__ . '/fixtures/testHtmlList.html')));
|
||||||
|
$actual = array_filter(array_map('trim', explode(PHP_EOL, $obj->getHtmlMenu($html, 1, 6))));
|
||||||
|
|
||||||
|
$this->assertEquals($fixture, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
public function testGetItemsMatchesOnlyElementsWithIDs()
|
public function testGetItemsMatchesOnlyElementsWithIDs()
|
||||||
{
|
{
|
||||||
$obj = new TocGenerator();
|
$html = "
|
||||||
|
<h1 id='a'>A-Header</h1><p>Foobar</p>
|
||||||
|
<h1 id='b'>B-Header</h1>
|
||||||
|
<h1>C-Header</h1>
|
||||||
|
";
|
||||||
|
|
||||||
$html = "<h1 id='a'>A Header</h1><p>Foobar</p><h2>B Header</h2><h3 id='c'>C Header</h3>";
|
$obj = new TocGenerator();
|
||||||
$this->assertEquals(['a' => 'A Header', 'c' => 'C Header'], $obj->getItems($html, 1, 3));
|
$menu = $obj->getMenu($html, 1);
|
||||||
|
|
||||||
|
$this->assertCount(2, $menu);
|
||||||
|
$this->assertEquals('A-Header', $menu->getFirstChild()->getLabel());
|
||||||
|
$this->assertEquals('B-Header', $menu->getLastChild()->getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
//
|
||||||
public function testGetItemsUsesTitleForDisplayTextWhenAvailableAndPlainTextWhenNot()
|
// public function testGetItemsUsesTitleForDisplayTextWhenAvailableAndPlainTextWhenNot()
|
||||||
{
|
// {
|
||||||
$obj = new TocGenerator();
|
// $obj = new TocGenerator();
|
||||||
|
//
|
||||||
$html = '<h1 id="a" title="Foo Bar!">A Header</h1>';
|
// $html = '<h1 id="a" title="Foo Bar!">A Header</h1>';
|
||||||
$html .= '<h2 id="b">B Header</h2>';
|
// $html .= '<h2 id="b">B Header</h2>';
|
||||||
$html .= '<h3 id="c" title="Baz Biz~">C Header</h3>';
|
// $html .= '<h3 id="c" title="Baz Biz~">C Header</h3>';
|
||||||
|
//
|
||||||
$this->assertEquals(
|
// $this->assertEquals(
|
||||||
['a' => 'Foo Bar!', 'b' => 'B Header', 'c' => 'Baz Biz~'],
|
// ['a' => 'Foo Bar!', 'b' => 'B Header', 'c' => 'Baz Biz~'],
|
||||||
$obj->getItems($html, 1, 3)
|
// $obj->getItems($html, 1, 3)
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// ---------------------------------------------------------------
|
// // ---------------------------------------------------------------
|
||||||
|
//
|
||||||
public function testGetItemsGetsOnlyHeaderLevelsSpecified()
|
// public function testGetItemsGetsOnlyHeaderLevelsSpecified()
|
||||||
{
|
// {
|
||||||
$obj = new TocGenerator();
|
// $obj = new TocGenerator();
|
||||||
|
//
|
||||||
$html = '<h1 id="a" title="Foo Bar!">A Header</h1>';
|
// $html = '<h1 id="a" title="Foo Bar!">A Header</h1>';
|
||||||
$html .= '<h2 id="b">B Header</h2>';
|
// $html .= '<h2 id="b">B Header</h2>';
|
||||||
$html .= '<h3 id="c" title="Baz Biz~">C Header</h3>';
|
// $html .= '<h3 id="c" title="Baz Biz~">C Header</h3>';
|
||||||
$html .= '<h4 id="d" title="Bal Baf#">D Header</h4>';
|
// $html .= '<h4 id="d" title="Bal Baf#">D Header</h4>';
|
||||||
$html .= '<h5 id="e" title="Cak Coy%">E Header</h5>';
|
// $html .= '<h5 id="e" title="Cak Coy%">E Header</h5>';
|
||||||
$html .= '<h6 id="f" title="Dar Dul^">F Header</h6>';
|
// $html .= '<h6 id="f" title="Dar Dul^">F Header</h6>';
|
||||||
|
//
|
||||||
$this->assertCount(1, $obj->getItems($html, 5, 1));
|
// $this->assertCount(1, $obj->getItems($html, 5, 1));
|
||||||
$this->assertCount(2, $obj->getItems($html, 5, 5));
|
// $this->assertCount(2, $obj->getItems($html, 5, 5));
|
||||||
$this->assertCount(6, $obj->getItems($html, -1, 20));
|
// $this->assertCount(6, $obj->getItems($html, -1, 20));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// ---------------------------------------------------------------
|
// // ---------------------------------------------------------------
|
||||||
|
//
|
||||||
public function testGetHtmlItemsReturnsExpectedListItems()
|
// public function testGetHtmlItemsReturnsExpectedListItems()
|
||||||
{
|
// {
|
||||||
$obj = new TocGenerator();
|
// $obj = new TocGenerator();
|
||||||
|
//
|
||||||
$html = '<h1 id="a" title="Foo Bar!">A Header</h1>';
|
// $html = '<h1 id="a" title="Foo Bar!">A Header</h1>';
|
||||||
$html .= '<h2 id="b">B Header</h2>';
|
// $html .= '<h2 id="b">B Header</h2>';
|
||||||
$html .= '<h3 id="c" title="Baz Biz~">C Header</h3>';
|
// $html .= '<h3 id="c" title="Baz Biz~">C Header</h3>';
|
||||||
|
//
|
||||||
$this->assertEquals(
|
// $this->assertEquals(
|
||||||
"<li><a title='Go to Foo Bar!' href='#a'>Foo Bar!</a></li><li><a title='Go to B Header' href='#b'>B Header</a></li><li><a title='Go to Baz Biz~' href='#c'>Baz Biz~</a></li>",
|
// "<li><a title='Go to Foo Bar!' href='#a'>Foo Bar!</a></li><li><a title='Go to B Header' href='#b'>B Header</a></li><li><a title='Go to Baz Biz~' href='#c'>Baz Biz~</a></li>",
|
||||||
$obj->getHtmlItems($html, 1, 3)
|
// $obj->getHtmlItems($html, 1, 3)
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// ---------------------------------------------------------------
|
// // ---------------------------------------------------------------
|
||||||
|
//
|
||||||
public function testGetItemsReturnsAnEmptyArrayWhenNoContentOrMatches()
|
// public function testGetItemsReturnsAnEmptyArrayWhenNoContentOrMatches()
|
||||||
{
|
// {
|
||||||
$obj = new TocGenerator();
|
// $obj = new TocGenerator();
|
||||||
$this->assertEquals([], $obj->getItems("<h1>Boo</h1><h2>Bar</h2>"));
|
// $this->assertEquals([], $obj->getItems("<h1>Boo</h1><h2>Bar</h2>"));
|
||||||
$this->assertEquals([], $obj->getItems(""));
|
// $this->assertEquals([], $obj->getItems(""));
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
tests/fixtures/testHtmlList.html
поставляемый
Обычный файл
44
tests/fixtures/testHtmlList.html
поставляемый
Обычный файл
@ -0,0 +1,44 @@
|
|||||||
|
<ul>
|
||||||
|
<li class="first">
|
||||||
|
<a href="#a">A-Header</a>
|
||||||
|
<ul class="menu_level_1">
|
||||||
|
<li class="first">
|
||||||
|
<a href="#b">B-Header</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#c">C-Header</a>
|
||||||
|
<ul class="menu_level_2">
|
||||||
|
<li class="first last">
|
||||||
|
<a href="#d">D-Header</a>
|
||||||
|
<ul class="menu_level_3">
|
||||||
|
<li class="first last">
|
||||||
|
<a href="#e">E-Header</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="last">
|
||||||
|
<a href="#f">F-Header</a>
|
||||||
|
<ul class="menu_level_2">
|
||||||
|
<li class="first last">
|
||||||
|
<span></span>
|
||||||
|
<ul class="menu_level_3">
|
||||||
|
<li class="first last">
|
||||||
|
<span></span>
|
||||||
|
<ul class="menu_level_4">
|
||||||
|
<li class="first last">
|
||||||
|
<a href="#g">G-Header</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="last">
|
||||||
|
<a href="#h">H-Header</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
Загрузка…
Ссылка в новой задаче
Block a user