Browse Source

update grav

master
freds 6 years ago
parent
commit
fc0ae798f6
  1. 33
      CHANGELOG.md
  2. 46
      CODE_OF_CONDUCT.md
  3. 138
      CONTRIBUTING.md
  4. 3
      LICENSE.txt
  5. 93
      README.md
  6. 9
      bin/gpm
  7. 15
      bin/grav
  8. 14
      bin/plugin
  9. 2
      composer.json
  10. 343
      composer.lock
  11. 19
      index.php
  12. 2
      system/defines.php
  13. 6
      system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
  14. 15
      system/src/Grav/Common/Data/BlueprintSchema.php
  15. 32
      system/src/Grav/Common/Data/Data.php
  16. 11
      system/src/Grav/Common/Data/Validation.php
  17. 36
      system/src/Grav/Common/Filesystem/Folder.php
  18. 23
      system/src/Grav/Common/Grav.php
  19. 8
      system/src/Grav/Common/Page/Page.php
  20. 48
      system/src/Grav/Common/Processors/InitializeProcessor.php
  21. 13
      system/src/Grav/Common/Service/PagesServiceProvider.php
  22. 2
      system/src/Grav/Common/Twig/TwigExtension.php
  23. 24
      system/src/Grav/Common/Uri.php
  24. 141
      system/src/Grav/Console/ConsoleCommand.php
  25. 54
      system/src/Grav/Framework/Session/Session.php
  26. 2
      vendor/autoload.php
  27. 4
      vendor/behat/gherkin/.gitignore
  28. 33
      vendor/behat/gherkin/.travis.yml
  29. 388
      vendor/behat/gherkin/CHANGES.md
  30. 33
      vendor/behat/gherkin/CONTRIBUTING.md
  31. 22
      vendor/behat/gherkin/LICENSE
  32. 68
      vendor/behat/gherkin/README.md
  33. 70
      vendor/behat/gherkin/bin/update_i18n
  34. 47
      vendor/behat/gherkin/composer.json
  35. 1197
      vendor/behat/gherkin/i18n.php
  36. 3
      vendor/behat/gherkin/libpath.php
  37. 71
      vendor/behat/gherkin/package.xml.tpl
  38. 14
      vendor/behat/gherkin/phpdoc.ini.dist
  39. 25
      vendor/behat/gherkin/phpunit.xml.dist
  40. 48
      vendor/behat/gherkin/src/Behat/Gherkin/Cache/CacheInterface.php
  41. 109
      vendor/behat/gherkin/src/Behat/Gherkin/Cache/FileCache.php
  42. 66
      vendor/behat/gherkin/src/Behat/Gherkin/Cache/MemoryCache.php
  43. 22
      vendor/behat/gherkin/src/Behat/Gherkin/Exception/CacheException.php
  44. 15
      vendor/behat/gherkin/src/Behat/Gherkin/Exception/Exception.php
  45. 17
      vendor/behat/gherkin/src/Behat/Gherkin/Exception/LexerException.php
  46. 17
      vendor/behat/gherkin/src/Behat/Gherkin/Exception/NodeException.php
  47. 17
      vendor/behat/gherkin/src/Behat/Gherkin/Exception/ParserException.php
  48. 52
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/ComplexFilter.php
  49. 32
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/ComplexFilterInterface.php
  50. 39
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/FeatureFilterInterface.php
  51. 30
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/FilterInterface.php
  52. 122
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/LineFilter.php
  53. 134
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/LineRangeFilter.php
  54. 68
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/NameFilter.php
  55. 61
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/NarrativeFilter.php
  56. 72
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/PathsFilter.php
  57. 63
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/RoleFilter.php
  58. 56
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/SimpleFilter.php
  59. 90
      vendor/behat/gherkin/src/Behat/Gherkin/Filter/TagFilter.php
  60. 142
      vendor/behat/gherkin/src/Behat/Gherkin/Gherkin.php
  61. 200
      vendor/behat/gherkin/src/Behat/Gherkin/Keywords/ArrayKeywords.php
  62. 31
      vendor/behat/gherkin/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php
  63. 121
      vendor/behat/gherkin/src/Behat/Gherkin/Keywords/CucumberKeywords.php
  64. 365
      vendor/behat/gherkin/src/Behat/Gherkin/Keywords/KeywordsDumper.php
  65. 103
      vendor/behat/gherkin/src/Behat/Gherkin/Keywords/KeywordsInterface.php
  66. 614
      vendor/behat/gherkin/src/Behat/Gherkin/Lexer.php
  67. 72
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/AbstractFileLoader.php
  68. 269
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/ArrayLoader.php
  69. 80
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/DirectoryLoader.php
  70. 26
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/FileLoaderInterface.php
  71. 102
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/GherkinFileLoader.php
  72. 39
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/LoaderInterface.php
  73. 73
      vendor/behat/gherkin/src/Behat/Gherkin/Loader/YamlFileLoader.php
  74. 20
      vendor/behat/gherkin/src/Behat/Gherkin/Node/ArgumentInterface.php
  75. 112
      vendor/behat/gherkin/src/Behat/Gherkin/Node/BackgroundNode.php
  76. 274
      vendor/behat/gherkin/src/Behat/Gherkin/Node/ExampleNode.php
  77. 57
      vendor/behat/gherkin/src/Behat/Gherkin/Node/ExampleTableNode.php
  78. 243
      vendor/behat/gherkin/src/Behat/Gherkin/Node/FeatureNode.php
  79. 33
      vendor/behat/gherkin/src/Behat/Gherkin/Node/KeywordNodeInterface.php
  80. 33
      vendor/behat/gherkin/src/Behat/Gherkin/Node/NodeInterface.php
  81. 218
      vendor/behat/gherkin/src/Behat/Gherkin/Node/OutlineNode.php
  82. 90
      vendor/behat/gherkin/src/Behat/Gherkin/Node/PyStringNode.php
  83. 20
      vendor/behat/gherkin/src/Behat/Gherkin/Node/ScenarioInterface.php
  84. 20
      vendor/behat/gherkin/src/Behat/Gherkin/Node/ScenarioLikeInterface.php
  85. 150
      vendor/behat/gherkin/src/Behat/Gherkin/Node/ScenarioNode.php
  86. 33
      vendor/behat/gherkin/src/Behat/Gherkin/Node/StepContainerInterface.php
  87. 152
      vendor/behat/gherkin/src/Behat/Gherkin/Node/StepNode.php
  88. 347
      vendor/behat/gherkin/src/Behat/Gherkin/Node/TableNode.php
  89. 42
      vendor/behat/gherkin/src/Behat/Gherkin/Node/TaggedNodeInterface.php
  90. 699
      vendor/behat/gherkin/src/Behat/Gherkin/Parser.php
  91. 75
      vendor/behat/gherkin/tests/Behat/Gherkin/Cache/FileCacheTest.php
  92. 51
      vendor/behat/gherkin/tests/Behat/Gherkin/Cache/MemoryCacheTest.php
  93. 64
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/FilterTest.php
  94. 0
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/Fixtures/full/file1
  95. 0
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/Fixtures/full/file2
  96. 0
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/Fixtures/full_path/file1
  97. 103
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/LineFilterTest.php
  98. 101
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/LineRangeFilterTest.php
  99. 79
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/NameFilterTest.php
  100. 34
      vendor/behat/gherkin/tests/Behat/Gherkin/Filter/NarrativeFilterTest.php
  101. Some files were not shown because too many files have changed in this diff Show More

33
CHANGELOG.md

@ -1,3 +1,34 @@
# v1.6.21
## 02/11/2020
1. [](#new)
* Added `ConsoleCommand::setLanguage()` method to set language to be used from CLI
* Added `ConsoleCommand::initializeGrav()` method to properly set up Grav instance to be used from CLI
* Added `ConsoleCommand::initializePlugins()`method to properly set up all plugins to be used from CLI
* Added `ConsoleCommand::initializeThemes()`method to properly set up current theme to be used from CLI
* Added `ConsoleCommand::initializePages()` method to properly set up pages to be used from CLI
1. [](#improved)
* Vendor updates
1. [](#bugfix)
* Fixed `bin/plugin` CLI calling `$themes->init()` way too early (removed it, use above methods instead)
* Fixed call to `$grav['page']` crashing CLI
* Fixed encoding problems when PHP INI setting `default_charset` is not `utf-8` [#2154](https://github.com/getgrav/grav/issues/2154)
# v1.6.20
## 02/03/2020
1. [](#bugfix)
* Fixed incorrect routing caused by `str_replace()` in `Uri::init()` [#2754](https://github.com/getgrav/grav/issues/2754)
* Fixed session cookie is being set twice in the HTTP header [#2745](https://github.com/getgrav/grav/issues/2745)
* Fixed session not restarting if user was invalid (downgrading from Grav 1.7)
* Fixed filesystem iterator calls with non-existing folders
* Fixed `checkbox` field not being saved, requires also Form v4.0.2 [#1225](https://github.com/getgrav/grav/issues/1225)
* Fixed `validation: strict` not working in blueprints [#1273](https://github.com/getgrav/grav/issues/1273)
* Fixed `Data::filter()` removing empty fields (such as empty list) by default [#2805](https://github.com/getgrav/grav/issues/2805)
* Fixed fatal error with non-integer page param value [#2803](https://github.com/getgrav/grav/issues/2803)
* Fixed `Assets::addInlineJs()` parameter type mismatch between v1.5 and v1.6 [#2659](https://github.com/getgrav/grav/issues/2659)
* Fixed `site.metadata` saving issues [#2615](https://github.com/getgrav/grav/issues/2615)
# v1.6.19
## 12/04/2019
@ -6,7 +37,7 @@
1. [](#bugfix)
* Fixed fatal error when calling `{{ grav.undefined }}`
* Fixed multiple issues when there are no pages in the site
* PHP 7.4 fix for [#2750](https://github.com/getgrav/grav/issues/2750)
* PHP 7.4 fix for [#2750](https://github.com/getgrav/grav/issues/2750)
# v1.6.18
## 12/02/2019

46
CODE_OF_CONDUCT.md

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@getgrav.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

138
CONTRIBUTING.md

@ -0,0 +1,138 @@
# Contributing to Grav
:+1::tada: First, thanks for getting involved with Grav! :tada::+1:
Please take a moment to review this document in order to make the contribution
process easy and effective for everyone involved.
Following these guidelines helps to communicate that you respect the time of
the developers managing and developing this open source project. In return,
they should reciprocate that respect in addressing your issue or assessing
patches and features.
## Grav, Plugins, Themes and Skeletons
Grav is a large open source project — it's made up of over 100 repositories. When you initially consider contributing to Grav, you might be unsure about which of those 200 repositories implements the functionality you want to change or report a bug for.
[https://github.com/getgrav/grav](https://github.com/getgrav/grav) is the main Grav repository. The core of Grav is provided by this repo.
[https://github.com/getgrav/grav-plugin-admin](https://github.com/getgrav/grav-plugin-admin) is the Admin Plugin repository.
Every Plugin and Theme has its own repository. If you have a problem you think is specific to a Theme or Plugin, please report it in its corresponding repository. Please read the Plugin or Theme documentation to ensure the problem is not addressed there already.
Every Skeleton also has its own repository, so if an issue is not specific to a theme or plugin but rather to its usage in the skeleton, report it in the skeleton repository.
## Using the issue tracker
The issue tracker is the preferred channel for [bug reports](#bugs),
[features requests](#features) and [submitting pull
requests](#pull-requests), but please respect the following restrictions:
* Please **do not** use the issue tracker for support requests. Use
[the Forum](http://getgrav.org/forum) or [the Chat](https://chat.getgrav.org/).
<a name="bugs"></a>
## Bug reports
A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful - thank you!
Guidelines for bug reports:
1. **Check you satisfy the Grav requirements** &mdash; [http://learn.getgrav.org/basics/requirements](http://learn.getgrav.org/basics/requirements)
2. **Check this happens on a clean Grav install** &mdash; check if the issue happens on any Grav site, or just with a specific configuration of plugins / theme
3. **Use the GitHub issue search** &mdash; check if the issue has already been
reported.
4. **Check if the issue is already being solved in a PR** &mdash; check the open Pull Requests to see if one already solves the problem you're having
5. **Check if the issue has been fixed** &mdash; try to reproduce it using the
latest `develop` branch in the repository.
6. **Isolate the problem** &mdash; create a [reduced test
case](http://css-tricks.com/reduced-test-cases/) and provide a step-by-step instruction set on how to recreate the problem. Include code samples, page snippets or yaml configurations if needed.
7. **Check the problem on Grav 1.1** &mdash; if you're using Grav 1.0, latest stable release, please also check if you can replicate the issue on Grav 1.1 RC as many bugs are already solved in the next Grav release.
A good bug report shouldn't leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report.
- What is your environment? Is it localhost, OSX, Linux, on a remote server? Same happening locally and or the server, or just locally or just on Linux?
- What steps will reproduce the issue? What browser(s) and OS experience the problem?
- What would you expect to be the outcome?
- Did the problem start happening recently (e.g. after updating to a new version of Grav) or was this always a problem?
- If the problem started happening recently, can you reproduce the problem in an older version of Grav? What's the most recent version in which the problem doesn't happen? You can download older versions of Grav from the releases page on Github.
- Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens.
All these details will help contributors to fix any potential bugs.
Important: [include Code Samples in triple backticks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) so that Github will provide a proper indentation. [Add the language name after the backticks](https://help.github.com/articles/github-flavored-markdown/#syntax-highlighting) to add syntax highlighting to the code snippets.
Example:
> Short and descriptive example bug report title
>
> A summary of the issue and the browser/OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>>
> Any other information you want to share that is relevant to the issue being
> reported. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).
<a name="features"></a>
## Feature requests
Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.
<a name="pull-requests"></a>
## Pull requests
Good pull requests - patches, improvements, new features - are a fantastic
help. They should remain focused in scope and avoid containing unrelated
commits.
**Please ask first** in [the Forum](http://getgrav.org/forum) or [the Chat](https://chat.getgrav.org/)
before embarking on any significant pull request (e.g.
implementing features, refactoring code..),
otherwise you risk spending a lot of time working on something that the
project's developers might not want to merge into the project.
Please adhere to the coding conventions used throughout the project (indentation,
accurate comments, etc.) and any other requirements.
See [Using Pull Request](https://help.github.com/articles/using-pull-requests/) and [Fork a Repo](https://help.github.com/articles/fork-a-repo/) if you're not familiar with Pull Requests.
Any pull request should be based on the `develop` branch. We will not consider pull requests made to master.
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
license your work under the same license as that used by the project.
<a name="translations"></a>
### Translations
Translations for Grav core and the Admin plugin are managed through Crowdin:
- Admin: https://crowdin.com/project/grav-admin
- Core: https://crowdin.com/project/grav-core
Please do not post translations PRs for core or admin translations on GitHub, with the exception of fixes for the english language.
All other plugins and themes translations are handled directly in their GitHub repository, and the string are usually found in the `languages.yaml` file at the root of each project.

3
vendor/phpdocumentor/reflection-common/LICENSE → LICENSE.txt

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 phpDocumentor
Copyright (c) 2018 Grav
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

93
README.md

@ -1,15 +1,17 @@
# Grav
# ![](https://avatars1.githubusercontent.com/u/8237355?v=2&s=50) Grav
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad/mini.png)](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad)
[![Discord](https://img.shields.io/discord/501836936584101899.svg?logo=discord&colorB=728ADA&label=Discord%20Chat)](https://chat.getgrav.org)
[![Build Status](https://travis-ci.org/getgrav/grav.svg?branch=develop)](https://travis-ci.org/getgrav/grav) [![OpenCollective](https://opencollective.com/grav/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/grav/sponsors/badge.svg)](#sponsors)
Grav is a **Fast**, **Simple**, and **Flexible**, file-based Web-platform. There is **Zero** installation required. Just extract the ZIP archive, and you are already up and running. It follows similar principles to other flat-file CMS platforms, but has a different design philosophy than most. Grav comes with a powerful **Package Management System** to allow for simple installation and upgrading of plugins and themes, as well as simple updating of Grav itself.
Grav is a **Fast**, **Simple**, and **Flexible**, file-based Web-platform.
The underlying architecture of Grav is designed to use well-established and _best-in-class_ technologies to ensure that Grav is simple to use and easy to extend. Some of these key technologies include:
* [Twig Templating](https://twig.sensiolabs.org/): for powerful control of the user interface
* [Markdown](https://en.wikipedia.org/wiki/Markdown): for easy content creation
* [YAML](https://yaml.org): for simple configuration
* Have a look at the Grav [Basic Tutorial](https://learn.getgrav.org/basics/basic-tutorial)
See also:
* [Parsedown](https://parsedown.org/): for fast Markdown and Markdown Extra support
* [Doctrine Cache](https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/caching.html): layer for performance
* [Pimple Dependency Injection Container](https://pimple.sensiolabs.org/): for extensibility and maintainability
@ -17,8 +19,47 @@ See also:
* [Symfony Console](https://symfony.com/doc/current/components/console/introduction.html): for CLI interface
* [Gregwar Image Library](https://github.com/Gregwar/Image): for dynamic image manipulation
# Requirements
- PHP 7.1.3 or higher. Check the [required modules list](https://learn.getgrav.org/basics/requirements#php-requirements)
- Check the [Apache](https://learn.getgrav.org/basics/requirements#apache-requirements) or [IIS](https://learn.getgrav.org/basics/requirements#iis-requirements) requirements
# QuickStart
These are the options to get Grav:
### Downloading a Grav Package
You can download a **ready-built** package from the [Downloads page on https://getgrav.org](https://getgrav.org/downloads)
### With Composer
You can create a new project with the latest **stable** Grav release with the following command:
```
$ composer create-project getgrav/grav ~/webroot/grav
```
### From GitHub
1. Clone the Grav repository from [https://github.com/getgrav/grav]() to a folder in the webroot of your server, e.g. `~/webroot/grav`. Launch a **terminal** or **console** and navigate to the webroot folder:
```
$ cd ~/webroot
$ git clone https://github.com/getgrav/grav.git
```
2. Install the **plugin** and **theme dependencies** by using the [Grav CLI application](https://learn.getgrav.org/advanced/grav-cli) `bin/grav`:
```
$ cd ~/webroot/grav
$ bin/grav install
```
Check out the [install procedures](https://learn.getgrav.org/basics/installation) for more information.
# Adding Functionality
You can download [plugins](https://getgrav.org/downloads/plugins) or [themes](https://getgrav.org/downloads/themes) manually from the appropriate tab on the [Downloads page on https://getgrav.org](https://getgrav.org/downloads), but the preferred solution is to use the [Grav Package Manager](https://learn.getgrav.org/advanced/grav-gpm) or `GPM`:
```
$ bin/gpm index
```
@ -44,6 +85,46 @@ $ bin/gpm update
```
# Contributing
We appreciate any contribution to Grav, whether it is related to bugs, grammar, or simply a suggestion or improvement! Please refer to the [Contributing guide](CONTRIBUTING.md) for more guidance on this topic.
## Security issues
If you discover a possible security issue related to Grav or one of its plugins, please email the core team at contact@getgrav.org and we'll address it as soon as possible.
# Getting Started
* [What is Grav?](https://learn.getgrav.org/basics/what-is-grav)
* [Install](https://learn.getgrav.org/basics/installation) Grav in few seconds
* Understand the [Configuration](https://learn.getgrav.org/basics/grav-configuration)
* Take a peek at our available free [Skeletons](https://getgrav.org/downloads/skeletons)
* If you have questions, jump on our [Discord Chat Server](https://chat.getgrav.org)!
* Have fun!
# Exploring More
* Have a look at our [Basic Tutorial](https://learn.getgrav.org/basics/basic-tutorial)
* Dive into more [advanced](https://learn.getgrav.org/advanced) functions
* Learn about the [Grav CLI](https://learn.getgrav.org/cli-console/grav-cli)
* Review examples in the [Grav Cookbook](https://learn.getgrav.org/cookbook)
* More [Awesome Grav Stuff](https://github.com/getgrav/awesome-grav)
# Backers
Support Grav with a monthly donation to help us continue development. [[Become a backer](https://opencollective.com/grav#backer)]
<img src="https://opencollective.com/grav/tiers/backers.svg?avatarHeight=36&width=600" />
# Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/grav#sponsor)]
<img src="https://opencollective.com/grav/tiers/sponsors.svg?avatarHeight=36&width=600" />
# License
See [LICENSE](LICENSE.txt)
[gitflow-model]: http://nvie.com/posts/a-successful-git-branching-model/
[gitflow-extensions]: https://github.com/nvie/gitflow
# Running Tests

9
bin/gpm

@ -28,6 +28,13 @@ if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');
if (!file_exists(GRAV_ROOT . '/index.php')) {
exit('FATAL: Must be run from ROOT directory of Grav!');
}
@ -55,7 +62,7 @@ $grav->setup($environment);
$grav['config']->init();
$grav['uri']->init();
$grav['users'];
$grav['accounts'];
$app = new Application('Grav Package Manager', GRAV_VERSION);
$app->addCommands(array(

15
bin/grav

@ -25,6 +25,17 @@ if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
}
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');
$climate = new League\CLImate\CLImate;
$climate->arguments->add([
'environment' => [
@ -42,10 +53,6 @@ $environment = $climate->arguments->get('environment');
$grav = Grav::instance(array('loader' => $autoload));
$grav->setup($environment);
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
if (!file_exists(GRAV_ROOT . '/index.php')) {
exit('FATAL: Must be run from ROOT directory of Grav!');
}

14
bin/plugin

@ -32,6 +32,13 @@ if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');
if (!file_exists(GRAV_ROOT . '/index.php')) {
exit('FATAL: Must be run from ROOT directory of Grav!');
}
@ -51,12 +58,7 @@ $environment = $climate->arguments->get('environment');
$grav = Grav::instance(array('loader' => $autoload));
$grav->setup($environment);
$grav['config']->init();
$grav['uri']->init();
$grav['users'];
$grav['plugins']->init();
$grav['themes']->init();
$grav->initializeCli();
$app = new Application('Grav Plugins Commands', GRAV_VERSION);
$pattern = '([A-Z]\w+Command\.php)';

2
composer.json

@ -44,7 +44,7 @@
"gregwar/image": "2.*",
"donatj/phpuseragentparser": "~0.10",
"pimple/pimple": "~3.2",
"rockettheme/toolbox": "~1.4",
"rockettheme/toolbox": "~1.4.0",
"maximebf/debugbar": "~1.15",
"league/climate": "^3.4",
"antoligy/dom-string-iterators": "^1.0",

343
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "171fc8a6af028b50024e0f5f8c3eca82",
"content-hash": "6fa1c3a012660bd9c614bcce56af871f",
"packages": [
{
"name": "antoligy/dom-string-iterators",
@ -52,16 +52,16 @@
},
{
"name": "composer/ca-bundle",
"version": "1.2.4",
"version": "1.2.6",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527"
"reference": "47fe531de31fca4a1b997f87308e7d7804348f7e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/47fe531de31fca4a1b997f87308e7d7804348f7e",
"reference": "47fe531de31fca4a1b997f87308e7d7804348f7e",
"shasum": ""
},
"require": {
@ -72,7 +72,7 @@
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8",
"psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0 || ^4.0"
"symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0"
},
"type": "library",
"extra": {
@ -104,7 +104,7 @@
"ssl",
"tls"
],
"time": "2019-08-30T08:44:50+00:00"
"time": "2020-01-13T10:02:55+00:00"
},
{
"name": "doctrine/cache",
@ -260,16 +260,16 @@
},
{
"name": "donatj/phpuseragentparser",
"version": "v0.14.0",
"version": "v0.15.0",
"source": {
"type": "git",
"url": "https://github.com/donatj/PhpUserAgent.git",
"reference": "199f22df0c3fd0fb7de024dedbd052064bfb34fb"
"reference": "283e5812d3a3f2deb62377c14b0d24191aba1595"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/199f22df0c3fd0fb7de024dedbd052064bfb34fb",
"reference": "199f22df0c3fd0fb7de024dedbd052064bfb34fb",
"url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/283e5812d3a3f2deb62377c14b0d24191aba1595",
"reference": "283e5812d3a3f2deb62377c14b0d24191aba1595",
"shasum": ""
},
"require": {
@ -307,7 +307,7 @@
"user agent",
"useragent"
],
"time": "2019-09-30T16:32:02+00:00"
"time": "2020-01-21T17:51:39+00:00"
},
{
"name": "dragonmantank/cron-expression",
@ -444,16 +444,16 @@
},
{
"name": "filp/whoops",
"version": "2.5.0",
"version": "2.7.1",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
"reference": "cde50e6720a39fdacb240159d3eea6865d51fd96"
"reference": "fff6f1e4f36be0e0d0b84d66b413d9dcb0c49130"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/cde50e6720a39fdacb240159d3eea6865d51fd96",
"reference": "cde50e6720a39fdacb240159d3eea6865d51fd96",
"url": "https://api.github.com/repos/filp/whoops/zipball/fff6f1e4f36be0e0d0b84d66b413d9dcb0c49130",
"reference": "fff6f1e4f36be0e0d0b84d66b413d9dcb0c49130",
"shasum": ""
},
"require": {
@ -462,8 +462,8 @@
},
"require-dev": {
"mockery/mockery": "^0.9 || ^1.0",
"phpunit/phpunit": "^4.8.35 || ^5.7",
"symfony/var-dumper": "^2.6 || ^3.0 || ^4.0"
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0",
"symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0"
},
"suggest": {
"symfony/var-dumper": "Pretty print complex values better with var-dumper available",
@ -472,7 +472,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
"dev-master": "2.6-dev"
}
},
"autoload": {
@ -501,7 +501,7 @@
"throwable",
"whoops"
],
"time": "2019-08-07T09:00:00+00:00"
"time": "2020-01-15T10:00:00+00:00"
},
{
"name": "gregwar/cache",
@ -787,16 +787,16 @@
},
{
"name": "matthiasmullie/minify",
"version": "1.3.61",
"version": "1.3.63",
"source": {
"type": "git",
"url": "https://github.com/matthiasmullie/minify.git",
"reference": "d5acb8ce5b6acb7d11bafe97cecc533f6e4fd751"
"reference": "9ba1b459828adc13430f4dd6c49dae4950dc4117"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/d5acb8ce5b6acb7d11bafe97cecc533f6e4fd751",
"reference": "d5acb8ce5b6acb7d11bafe97cecc533f6e4fd751",
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/9ba1b459828adc13430f4dd6c49dae4950dc4117",
"reference": "9ba1b459828adc13430f4dd6c49dae4950dc4117",
"shasum": ""
},
"require": {
@ -843,20 +843,20 @@
"minifier",
"minify"
],
"time": "2018-11-26T23:10:39+00:00"
"time": "2020-01-21T20:21:08+00:00"
},
{
"name": "matthiasmullie/path-converter",
"version": "1.1.2",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/matthiasmullie/path-converter.git",
"reference": "5e4b121c8b9f97c80835c1d878b0812ba1d607c9"
"reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/5e4b121c8b9f97c80835c1d878b0812ba1d607c9",
"reference": "5e4b121c8b9f97c80835c1d878b0812ba1d607c9",
"url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/e7d13b2c7e2f2268e1424aaed02085518afa02d9",
"reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9",
"shasum": ""
},
"require": {
@ -892,26 +892,26 @@
"paths",
"relative"
],
"time": "2018-10-25T15:19:41+00:00"
"time": "2019-02-05T23:41:09+00:00"
},
{
"name": "maximebf/debugbar",
"version": "v1.16.0",
"version": "v1.16.1",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "6ca3502de5e5889dc21311d2461f8cc3b6a094b1"
"reference": "58998b818c6567fac01e35b8a4b70c1a64530556"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6ca3502de5e5889dc21311d2461f8cc3b6a094b1",
"reference": "6ca3502de5e5889dc21311d2461f8cc3b6a094b1",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/58998b818c6567fac01e35b8a4b70c1a64530556",
"reference": "58998b818c6567fac01e35b8a4b70c1a64530556",
"shasum": ""
},
"require": {
"php": "^7.1",
"psr/log": "^1.0",
"symfony/var-dumper": "^2.6|^3|^4"
"symfony/var-dumper": "^2.6|^3|^4|^5"
},
"require-dev": {
"phpunit/phpunit": "^5"
@ -953,7 +953,7 @@
"debug",
"debugbar"
],
"time": "2019-10-18T14:34:16+00:00"
"time": "2019-11-24T09:46:11+00:00"
},
{
"name": "miljar/php-exif",
@ -1013,16 +1013,16 @@
},
{
"name": "monolog/monolog",
"version": "1.25.2",
"version": "1.25.3",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "d5e2fb341cb44f7e2ab639d12a1e5901091ec287"
"reference": "fa82921994db851a8becaf3787a9e73c5976b6f1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/d5e2fb341cb44f7e2ab639d12a1e5901091ec287",
"reference": "d5e2fb341cb44f7e2ab639d12a1e5901091ec287",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fa82921994db851a8becaf3787a9e73c5976b6f1",
"reference": "fa82921994db851a8becaf3787a9e73c5976b6f1",
"shasum": ""
},
"require": {
@ -1087,7 +1087,7 @@
"logging",
"psr-3"
],
"time": "2019-11-13T10:00:05+00:00"
"time": "2019-12-20T14:15:16+00:00"
},
{
"name": "nyholm/psr7",
@ -2518,16 +2518,16 @@
},
{
"name": "twig/twig",
"version": "v1.42.4",
"version": "v1.42.5",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152"
"reference": "87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e587180584c3d2d6cb864a0454e777bb6dcb6152",
"reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e",
"reference": "87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e",
"shasum": ""
},
"require": {
@ -2536,8 +2536,7 @@
},
"require-dev": {
"psr/container": "^1.0",
"symfony/debug": "^3.4|^4.2",
"symfony/phpunit-bridge": "^4.4@dev|^5.0"
"symfony/phpunit-bridge": "^4.4|^5.0"
},
"type": "library",
"extra": {
@ -2566,7 +2565,6 @@
},
{
"name": "Twig Team",
"homepage": "https://twig.symfony.com/contributors",
"role": "Contributors"
},
{
@ -2580,7 +2578,7 @@
"keywords": [
"templating"
],
"time": "2019-11-11T16:49:32+00:00"
"time": "2020-02-11T05:59:23+00:00"
},
{
"name": "willdurand/negotiation",
@ -2789,16 +2787,16 @@
},
{
"name": "codeception/phpunit-wrapper",
"version": "7.7.2",
"version": "7.8.0",
"source": {
"type": "git",
"url": "https://github.com/Codeception/phpunit-wrapper.git",
"reference": "4ed12e8022f960e34fd78129e5dac34ce5b3a0ef"
"reference": "bc847bd4f8f6d09012543e2a856f19fe4ecdcf3a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/4ed12e8022f960e34fd78129e5dac34ce5b3a0ef",
"reference": "4ed12e8022f960e34fd78129e5dac34ce5b3a0ef",
"url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/bc847bd4f8f6d09012543e2a856f19fe4ecdcf3a",
"reference": "bc847bd4f8f6d09012543e2a856f19fe4ecdcf3a",
"shasum": ""
},
"require": {
@ -2828,7 +2826,7 @@
}
],
"description": "PHPUnit classes used by Codeception",
"time": "2019-11-23T18:21:46+00:00"
"time": "2019-12-23T06:55:58+00:00"
},
{
"name": "codeception/stub",
@ -3018,20 +3016,21 @@
"selenium",
"webdriver"
],
"abandoned": "php-webdriver/webdriver",
"time": "2019-06-13T08:02:18+00:00"
},
{
"name": "fzaninotto/faker",
"version": "v1.9.0",
"version": "v1.9.1",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "27a216cbe72327b2d6369fab721a5843be71e57d"
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/27a216cbe72327b2d6369fab721a5843be71e57d",
"reference": "27a216cbe72327b2d6369fab721a5843be71e57d",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f",
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f",
"shasum": ""
},
"require": {
@ -3044,7 +3043,9 @@
},
"type": "library",
"extra": {
"branch-alias": []
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"autoload": {
"psr-4": {
@ -3066,20 +3067,20 @@
"faker",
"fixtures"
],
"time": "2019-11-14T13:13:06+00:00"
"time": "2019-12-12T13:22:17+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "6.4.1",
"version": "6.5.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "0895c932405407fd3a7368b6910c09a24d26db11"
"reference": "43ece0e75098b7ecd8d13918293029e555a50f82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
"reference": "0895c932405407fd3a7368b6910c09a24d26db11",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82",
"reference": "43ece0e75098b7ecd8d13918293029e555a50f82",
"shasum": ""
},
"require": {
@ -3094,12 +3095,13 @@
"psr/log": "^1.1"
},
"suggest": {
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.3-dev"
"dev-master": "6.5-dev"
}
},
"autoload": {
@ -3132,7 +3134,7 @@
"rest",
"web service"
],
"time": "2019-10-23T15:58:00+00:00"
"time": "2019-12-23T11:57:10+00:00"
},
{
"name": "guzzlehttp/promises",
@ -3238,16 +3240,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.9.3",
"version": "1.9.5",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea"
"reference": "b2c28789e80a97badd14145fda39b545d83ca3ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea",
"reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef",
"reference": "b2c28789e80a97badd14145fda39b545d83ca3ef",
"shasum": ""
},
"require": {
@ -3282,7 +3284,7 @@
"object",
"object graph"
],
"time": "2019-08-09T12:45:53+00:00"
"time": "2020-01-17T21:11:47+00:00"
},
{
"name": "nette/bootstrap",
@ -3362,25 +3364,25 @@
},
{
"name": "nette/di",
"version": "v3.0.1",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/nette/di.git",
"reference": "4aff517a1c6bb5c36fa09733d4cea089f529de6d"
"reference": "77d69061cbf8f9cfb7363dd983136f51213d3e41"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/di/zipball/4aff517a1c6bb5c36fa09733d4cea089f529de6d",
"reference": "4aff517a1c6bb5c36fa09733d4cea089f529de6d",
"url": "https://api.github.com/repos/nette/di/zipball/77d69061cbf8f9cfb7363dd983136f51213d3e41",
"reference": "77d69061cbf8f9cfb7363dd983136f51213d3e41",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/neon": "^3.0",
"nette/php-generator": "^3.2.2",
"nette/php-generator": "^3.3.3",
"nette/robot-loader": "^3.2",
"nette/schema": "^1.0",
"nette/utils": "^3.0",
"nette/utils": "^3.1",
"php": ">=7.1"
},
"conflict": {
@ -3388,6 +3390,7 @@
},
"require-dev": {
"nette/tester": "^2.2",
"phpstan/phpstan": "^0.12",
"tracy/tracy": "^2.3"
},
"type": "library",
@ -3399,16 +3402,13 @@
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/compatibility.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
@ -3431,24 +3431,24 @@
"nette",
"static"
],
"time": "2019-08-07T12:11:33+00:00"
"time": "2020-01-20T12:14:54+00:00"
},
{
"name": "nette/finder",
"version": "v2.5.1",
"version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/nette/finder.git",
"reference": "14164e1ddd69e9c5f627ff82a10874b3f5bba5fe"
"reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/finder/zipball/14164e1ddd69e9c5f627ff82a10874b3f5bba5fe",
"reference": "14164e1ddd69e9c5f627ff82a10874b3f5bba5fe",
"url": "https://api.github.com/repos/nette/finder/zipball/4ad2c298eb8c687dd0e74ae84206a4186eeaed50",
"reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50",
"shasum": ""
},
"require": {
"nette/utils": "^2.4 || ~3.0.0",
"nette/utils": "^2.4 || ^3.0",
"php": ">=7.1"
},
"conflict": {
@ -3456,6 +3456,7 @@
},
"require-dev": {
"nette/tester": "^2.0",
"phpstan/phpstan": "^0.12",
"tracy/tracy": "^2.3"
},
"type": "library",
@ -3493,35 +3494,36 @@
"iterator",
"nette"
],
"time": "2019-07-11T18:02:17+00:00"
"time": "2020-01-03T20:35:40+00:00"
},
{
"name": "nette/neon",
"version": "v3.0.0",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/nette/neon.git",
"reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb"
"reference": "0a18fc88801a14d66587932de133eeca01f7ce8e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb",
"reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb",
"url": "https://api.github.com/repos/nette/neon/zipball/0a18fc88801a14d66587932de133eeca01f7ce8e",
"reference": "0a18fc88801a14d66587932de133eeca01f7ce8e",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"ext-json": "*",
"php": ">=7.0"
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "^2.0",
"phpstan/phpstan": "^0.12",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -3545,7 +3547,7 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette NEON: encodes and decodes NEON file format.",
"description": "🍸 Nette NEON: encodes and decodes NEON file format.",
"homepage": "http://ne-on.org",
"keywords": [
"export",
@ -3554,28 +3556,29 @@
"nette",
"yaml"
],
"time": "2019-02-05T21:30:40+00:00"
"time": "2019-12-27T04:00:04+00:00"
},
{
"name": "nette/php-generator",
"version": "v3.3.1",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/nette/php-generator.git",
"reference": "4240fd7adf499138c07b814ef9b9a6df9f6d7187"
"reference": "8fe7e699dca7db186f56d75800cb1ec32e39c856"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/php-generator/zipball/4240fd7adf499138c07b814ef9b9a6df9f6d7187",
"reference": "4240fd7adf499138c07b814ef9b9a6df9f6d7187",
"url": "https://api.github.com/repos/nette/php-generator/zipball/8fe7e699dca7db186f56d75800cb1ec32e39c856",
"reference": "8fe7e699dca7db186f56d75800cb1ec32e39c856",
"shasum": ""
},
"require": {
"nette/utils": "^2.4.2 || ~3.0.0",
"nette/utils": "^2.4.2 || ^3.0",
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "^2.0",
"phpstan/phpstan": "^0.12",
"tracy/tracy": "^2.3"
},
"type": "library",
@ -3592,8 +3595,8 @@
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
@ -3605,7 +3608,7 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.",
"description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.4 features.",
"homepage": "https://nette.org",
"keywords": [
"code",
@ -3613,30 +3616,31 @@
"php",
"scaffolding"
],
"time": "2019-11-22T11:12:11+00:00"
"time": "2020-02-09T14:39:09+00:00"
},
{
"name": "nette/robot-loader",
"version": "v3.2.0",
"version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/nette/robot-loader.git",
"reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c"
"reference": "d2a100e1f5cab390c78bc88709abbc91249c3993"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c",
"reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c",
"url": "https://api.github.com/repos/nette/robot-loader/zipball/d2a100e1f5cab390c78bc88709abbc91249c3993",
"reference": "d2a100e1f5cab390c78bc88709abbc91249c3993",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/finder": "^2.5",
"nette/finder": "^2.5 || ^3.0",
"nette/utils": "^3.0",
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "^2.0",
"phpstan/phpstan": "^0.12",
"tracy/tracy": "^2.3"
},
"type": "library",
@ -3666,7 +3670,7 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.",
"description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.",
"homepage": "https://nette.org",
"keywords": [
"autoload",
@ -3675,35 +3679,34 @@
"nette",
"trait"
],
"time": "2019-03-08T21:57:24+00:00"
"time": "2019-12-26T22:32:02+00:00"
},
{
"name": "nette/schema",
"version": "v1.0.1",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/nette/schema.git",
"reference": "337117df1dade22e2ba1fdc4a4b832c1e9b06b76"
"reference": "febf71fb4052c824046f5a33f4f769a6e7fa0cb4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/schema/zipball/337117df1dade22e2ba1fdc4a4b832c1e9b06b76",
"reference": "337117df1dade22e2ba1fdc4a4b832c1e9b06b76",
"url": "https://api.github.com/repos/nette/schema/zipball/febf71fb4052c824046f5a33f4f769a6e7fa0cb4",
"reference": "febf71fb4052c824046f5a33f4f769a6e7fa0cb4",
"shasum": ""
},
"require": {
"nette/utils": "^3.0.1",
"nette/utils": "^3.1",
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "^2.2",
"phpstan/phpstan-nette": "^0.12",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
"branch-alias": []
},
"autoload": {
"classmap": [
@ -3732,20 +3735,20 @@
"config",
"nette"
],
"time": "2019-10-31T20:52:19+00:00"
"time": "2020-01-06T22:52:48+00:00"
},
{
"name": "nette/utils",
"version": "v3.0.2",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "c133e18c922dcf3ad07673077d92d92cef25a148"
"reference": "2c17d16d8887579ae1c0898ff94a3668997fd3eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/c133e18c922dcf3ad07673077d92d92cef25a148",
"reference": "c133e18c922dcf3ad07673077d92d92cef25a148",
"url": "https://api.github.com/repos/nette/utils/zipball/2c17d16d8887579ae1c0898ff94a3668997fd3eb",
"reference": "2c17d16d8887579ae1c0898ff94a3668997fd3eb",
"shasum": ""
},
"require": {
@ -3753,6 +3756,7 @@
},
"require-dev": {
"nette/tester": "~2.0",
"phpstan/phpstan": "^0.12",
"tracy/tracy": "^2.3"
},
"suggest": {
@ -3767,7 +3771,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -3778,8 +3782,8 @@
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
@ -3809,7 +3813,7 @@
"utility",
"validation"
],
"time": "2019-10-21T20:40:16+00:00"
"time": "2020-02-09T14:10:55+00:00"
},
{
"name": "nikic/php-parser",
@ -4069,16 +4073,16 @@
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "4.3.2",
"version": "4.3.4",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e"
"reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e",
"reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c",
"reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c",
"shasum": ""
},
"require": {
@ -4090,6 +4094,7 @@
"require-dev": {
"doctrine/instantiator": "^1.0.5",
"mockery/mockery": "^1.0",
"phpdocumentor/type-resolver": "0.4.*",
"phpunit/phpunit": "^6.4"
},
"type": "library",
@ -4116,7 +4121,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2019-09-12T14:27:41+00:00"
"time": "2019-12-28T18:55:12+00:00"
},
{
"name": "phpdocumentor/type-resolver",
@ -4167,33 +4172,33 @@
},
{
"name": "phpspec/prophecy",
"version": "1.9.0",
"version": "v1.10.2",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203"
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203",
"reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0",
"sebastian/comparator": "^1.1|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
"sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5|^3.2",
"phpspec/phpspec": "^2.5 || ^3.2",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
"dev-master": "1.10.x-dev"
}
},
"autoload": {
@ -4226,7 +4231,7 @@
"spy",
"stub"
],
"time": "2019-10-03T11:07:50+00:00"
"time": "2020-01-20T15:57:02+00:00"
},
{
"name": "phpstan/phpdoc-parser",
@ -4655,16 +4660,16 @@
},
{
"name": "phpunit/phpunit",
"version": "7.5.17",
"version": "7.5.20",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a"
"reference": "9467db479d1b0487c99733bb1e7944d32deded2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4c92a15296e58191a4cd74cff3b34fc8e374174a",
"reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c",
"reference": "9467db479d1b0487c99733bb1e7944d32deded2c",
"shasum": ""
},
"require": {
@ -4735,7 +4740,7 @@
"testing",
"xunit"
],
"time": "2019-10-28T10:37:36+00:00"
"time": "2020-01-08T08:45:45+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -5305,16 +5310,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v4.4.1",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
"reference": "e19e465c055137938afd40cfddd687e7511bbbf0"
"reference": "45cae6dd8683d2de56df7ec23638e9429c70135f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/e19e465c055137938afd40cfddd687e7511bbbf0",
"reference": "e19e465c055137938afd40cfddd687e7511bbbf0",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/45cae6dd8683d2de56df7ec23638e9429c70135f",
"reference": "45cae6dd8683d2de56df7ec23638e9429c70135f",
"shasum": ""
},
"require": {
@ -5360,20 +5365,20 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2019-10-28T20:30:34+00:00"
"time": "2020-01-04T13:00:46+00:00"
},
{
"name": "symfony/css-selector",
"version": "v4.4.1",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "64acec7e0d67125e9f4656c68d4a38a42ab5a0b7"
"reference": "a167b1860995b926d279f9bb538f873e3bfa3465"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/64acec7e0d67125e9f4656c68d4a38a42ab5a0b7",
"reference": "64acec7e0d67125e9f4656c68d4a38a42ab5a0b7",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/a167b1860995b926d279f9bb538f873e3bfa3465",
"reference": "a167b1860995b926d279f9bb538f873e3bfa3465",
"shasum": ""
},
"require": {
@ -5413,20 +5418,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2019-10-12T00:35:04+00:00"
"time": "2020-01-04T13:00:46+00:00"
},
{
"name": "symfony/dom-crawler",
"version": "v4.4.1",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "36bbcab9369fc2f583220890efd43bf262d563fd"
"reference": "b66fe8ccc850ea11c4cd31677706c1219768bea1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/36bbcab9369fc2f583220890efd43bf262d563fd",
"reference": "36bbcab9369fc2f583220890efd43bf262d563fd",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b66fe8ccc850ea11c4cd31677706c1219768bea1",
"reference": "b66fe8ccc850ea11c4cd31677706c1219768bea1",
"shasum": ""
},
"require": {
@ -5474,20 +5479,20 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2019-10-29T11:38:30+00:00"
"time": "2020-01-04T13:00:46+00:00"
},
{
"name": "symfony/finder",
"version": "v4.4.1",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e"
"reference": "3a50be43515590faf812fbd7708200aabc327ec3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/ce8743441da64c41e2a667b8eb66070444ed911e",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e",
"url": "https://api.github.com/repos/symfony/finder/zipball/3a50be43515590faf812fbd7708200aabc327ec3",
"reference": "3a50be43515590faf812fbd7708200aabc327ec3",
"shasum": ""
},
"require": {
@ -5523,7 +5528,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2019-11-17T21:56:56+00:00"
"time": "2020-01-04T13:00:46+00:00"
},
{
"name": "theseer/tokenizer",

19
index.php

@ -20,6 +20,16 @@ if (PHP_SAPI === 'cli-server' && !isset($_SERVER['PHP_CLI_ROUTER'])) {
die("PHP webserver requires a router to run Grav, please use: <pre>php -S {$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']} system/router.php</pre>");
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');
// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($autoload)) {
@ -32,15 +42,6 @@ $loader = require $autoload;
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding if mbstring loaded
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
mb_internal_encoding('UTF-8');
// Get the Grav instance
$grav = Grav::instance(
array(

2
system/defines.php

@ -8,7 +8,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.6.19');
define('GRAV_VERSION', '1.6.21');
define('GRAV_TESTING', false);
define('DS', '/');

6
system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php

@ -51,7 +51,11 @@ trait LegacyAssetsTrait
// special case to handle old attributes being passed in
if (isset($arguments['attributes'])) {
$old_attributes = $arguments['attributes'];
$arguments = array_merge($arguments, $old_attributes);
if (is_array($old_attributes)) {
$arguments = array_merge($arguments, $old_attributes);
} else {
$arguments['type'] = $old_attributes;
}
}
unset($arguments['attributes']);

15
system/src/Grav/Common/Data/BlueprintSchema.php

@ -53,7 +53,7 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
public function validate(array $data)
{
try {
$messages = $this->validateArray($data, $this->nested);
$messages = $this->validateArray($data, $this->nested, $this->items['']['form'] ?? []);
} catch (\RuntimeException $e) {
throw (new ValidationException($e->getMessage(), $e->getCode(), $e))->setMessages();
@ -129,14 +129,15 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
/**
* @param array $data
* @param array $rules
* @param array $parent
* @return array
* @throws \RuntimeException
*/
protected function validateArray(array $data, array $rules)
protected function validateArray(array $data, array $rules, array $parent)
{
$messages = $this->checkRequired($data, $rules);
foreach ($data as $key => $field) {
foreach ($data as $key => $child) {
$val = $rules[$key] ?? $rules['*'] ?? null;
$rule = \is_string($val) ? $this->items[$val] : null;
@ -147,11 +148,11 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
continue;
}
$messages += Validation::validate($field, $rule);
} elseif (\is_array($field) && \is_array($val)) {
$messages += Validation::validate($child, $rule);
} elseif (\is_array($child) && \is_array($val)) {
// Array has been defined in blueprints.
$messages += $this->validateArray($field, $val);
} elseif (isset($rules['validation']) && $rules['validation'] === 'strict') {
$messages += $this->validateArray($child, $val, $rule ?? []);
} elseif (isset($parent['validation']) && $parent['validation'] === 'strict') {
// Undefined/extra item.
throw new \RuntimeException(sprintf('%s is not defined in blueprints', $key));
}

32
system/src/Grav/Common/Data/Data.php

@ -32,6 +32,12 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
/** @var File */
protected $storage;
/** @var bool */
private $missingValuesAsNull = false;
/** @var bool */
private $keepEmptyValues = true;
/**
* @param array $items
* @param Blueprint|callable $blueprints
@ -42,6 +48,28 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
$this->blueprints = $blueprints;
}
/**
* @param bool $value
* @return $this
*/
public function setKeepEmptyValues(bool $value)
{
$this->keepEmptyValues = $value;
return $this;
}
/**
* @param bool $value
* @return $this
*/
public function setMissingValuesAsNull(bool $value)
{
$this->missingValuesAsNull = $value;
return $this;
}
/**
* Get value by using dot notation for nested arrays/objects.
*
@ -202,8 +230,8 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
public function filter()
{
$args = func_get_args();
$missingValuesAsNull = (bool)(array_shift($args) ?: false);
$keepEmptyValues = (bool)(array_shift($args) ?: false);
$missingValuesAsNull = (bool)(array_shift($args) ?? $this->missingValuesAsNull);
$keepEmptyValues = (bool)(array_shift($args) ?? $this->keepEmptyValues);
$this->items = $this->blueprints()->filter($this->items, $missingValuesAsNull, $keepEmptyValues);

11
system/src/Grav/Common/Data/Validation.php

@ -166,9 +166,18 @@ class Validation
return (string) $value;
}
/**
* @param mixed $value
* @param array $params
* @param array $field
* @return string|null
*/
protected static function filterCheckbox($value, array $params, array $field)
{
return (bool) $value;
$value = (string)$value;
$field_value = (string)($field['value'] ?? '1');
return $value === $field_value ? $value : null;
}
protected static function filterCommaList($value, array $params, array $field)

36
system/src/Grav/Common/Filesystem/Folder.php

@ -22,6 +22,10 @@ abstract class Folder
*/
public static function lastModifiedFolder($path)
{
if (!file_exists($path)) {
return 0;
}
$last_modified = 0;
/** @var UniformResourceLocator $locator */
@ -56,6 +60,10 @@ abstract class Folder
*/
public static function lastModifiedFile($path, $extensions = 'md|yaml')
{
if (!file_exists($path)) {
return 0;
}
$last_modified = 0;
/** @var UniformResourceLocator $locator */
@ -92,21 +100,24 @@ abstract class Folder
*/
public static function hashAllFiles($path)
{
$flags = \RecursiveDirectoryIterator::SKIP_DOTS;
$files = [];
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
if ($locator->isStream($path)) {
$directory = $locator->getRecursiveIterator($path, $flags);
} else {
$directory = new \RecursiveDirectoryIterator($path, $flags);
}
if (file_exists($path)) {
$flags = \RecursiveDirectoryIterator::SKIP_DOTS;
$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
if ($locator->isStream($path)) {
$directory = $locator->getRecursiveIterator($path, $flags);
} else {
$directory = new \RecursiveDirectoryIterator($path, $flags);
}
foreach ($iterator as $file) {
$files[] = $file->getPathname() . '?'. $file->getMTime();
$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file) {
$files[] = $file->getPathname() . '?'. $file->getMTime();
}
}
return md5(serialize($files));
@ -199,6 +210,9 @@ abstract class Folder
if ($path === false) {
throw new \RuntimeException("Path doesn't exist.");
}
if (!file_exists($path)) {
return [];
}
$compare = isset($params['compare']) ? 'get' . $params['compare'] : null;
$pattern = $params['pattern'] ?? null;

23
system/src/Grav/Common/Grav.php

@ -170,6 +170,29 @@ class Grav extends Container
return $this;
}
/**
* Initialize CLI environment.
*
* Call after `$grav->setup($environment)`
*
* - Load configuration
* - Disable debugger
* - Set timezone, locale
* - Load plugins
* - Set Users type to be used in the site
*
* This method WILL NOT initialize assets, twig or pages.
*
* @param string|null $environment
* @return $this
*/
public function initializeCli()
{
InitializeProcessor::initializeCli($this);
return $this;
}
/**
* Process a request
*/

8
system/src/Grav/Common/Page/Page.php

@ -608,12 +608,12 @@ class Page implements PageInterface
return $content;
}
return mb_strimwidth($content, 0, $size, '...', 'utf-8');
return mb_strimwidth($content, 0, $size, '...', 'UTF-8');
}
$summary = Utils::truncateHtml($content, $size);
return html_entity_decode($summary);
return html_entity_decode($summary, ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
/**
@ -1694,7 +1694,7 @@ class Page implements PageInterface
$metadata['generator'] = 'GravCMS';
// Get initial metadata for the page
$metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata'));
$metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata', []));
if (isset($this->header->metadata) && is_array($this->header->metadata)) {
// Merge any site.metadata settings in with page metadata
@ -2828,7 +2828,7 @@ class Page implements PageInterface
if ($pagination) {
$params = $collection->params();
$limit = $params['limit'] ?? 0;
$limit = (int)($params['limit'] ?? 0);
$start = !empty($params['pagination']) ? ($uri->currentPage() - 1) * $limit : 0;
if ($limit && $collection->count() > $limit) {

48
system/src/Grav/Common/Processors/InitializeProcessor.php

@ -10,6 +10,7 @@
namespace Grav\Common\Processors;
use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Uri;
use Grav\Common\Utils;
use Grav\Framework\Session\Exceptions\SessionException;
@ -22,6 +23,22 @@ class InitializeProcessor extends ProcessorBase
public $id = 'init';
public $title = 'Initialize';
/** @var bool */
private static $cli_initialized = false;
/**
* @param Grav $grav
*/
public static function initializeCli(Grav $grav)
{
if (!static::$cli_initialized) {
static::$cli_initialized = true;
$instance = new static($grav);
$instance->processCli();
}
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{
$this->startTimer();
@ -77,4 +94,35 @@ class InitializeProcessor extends ProcessorBase
return $handler->handle($request);
}
public function processCli(): void
{
// Load configuration.
$this->container['config']->init();
$this->container['plugins']->setup();
// Disable debugger.
$this->container['debugger']->enabled(false);
// Set timezone, locale.
/** @var Config $config */
$config = $this->container['config'];
$timezone = $config->get('system.timezone');
if ($timezone) {
date_default_timezone_set($timezone);
}
$this->container->setLocale();
// Load plugins.
$this->container['plugins']->init();
// Initialize URI.
/** @var Uri $uri */
$uri = $this->container['uri'];
$uri->init();
// Load accounts.
// TODO: remove in 2.0.
$this->container['accounts'];
}
}

13
system/src/Grav/Common/Service/PagesServiceProvider.php

@ -26,6 +26,19 @@ class PagesServiceProvider implements ServiceProviderInterface
return new Pages($c);
};
if (\defined('GRAV_CLI')) {
$container['page'] = static function ($c) {
$path = $c['locator']->findResource('system://pages/notfound.md');
$page = new Page();
$page->init(new \SplFileInfo($path));
$page->routable(false);
return $page;
};
return;
}
$container['page'] = function ($c) {
/** @var Grav $c */

2
system/src/Grav/Common/Twig/TwigExtension.php

@ -1055,7 +1055,7 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*/
public function jsonDecodeFilter($str, $assoc = false, $depth = 512, $options = 0)
{
return json_decode(html_entity_decode($str), $assoc, $depth, $options);
return json_decode(html_entity_decode($str, ENT_COMPAT | ENT_HTML401, 'UTF-8'), $assoc, $depth, $options);
}
/**

24
system/src/Grav/Common/Uri.php

@ -151,7 +151,7 @@ class Uri
$this->url = $this->base . $this->uri;
$uri = str_replace(static::filterPath($this->root), '', $this->url);
$uri = Utils::replaceFirstOccurrence(static::filterPath($this->root), '', $this->url);
// remove the setup.php based base if set:
$setup_base = $grav['pages']->base();
@ -195,7 +195,7 @@ class Uri
// set the new url
$this->url = $this->root . $path;
$this->path = static::cleanPath($path);
$this->content_path = trim(str_replace($this->base, '', $this->path), '/');
$this->content_path = trim(Utils::replaceFirstOccurrence($this->base, '', $this->path), '/');
if ($this->content_path !== '') {
$this->paths = explode('/', $this->content_path);
}
@ -306,7 +306,7 @@ class Uri
public function param($id)
{
if (isset($this->params[$id])) {
return html_entity_decode(rawurldecode($this->params[$id]));
return html_entity_decode(rawurldecode($this->params[$id]), ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
return false;
@ -340,7 +340,7 @@ class Uri
return $this->url;
}
$url = str_replace($this->base, '', rtrim($this->url, '/'));
$url = Utils::replaceFirstOccurrence($this->base, '', rtrim($this->url, '/'));
return $url ?: '/';
}
@ -489,7 +489,7 @@ class Uri
return $this->uri;
}
return str_replace($this->root_path, '', $this->uri);
return Utils::replaceFirstOccurrence($this->root_path, '', $this->uri);
}
/**
@ -531,7 +531,7 @@ class Uri
return $this->root;
}
return str_replace($this->base, '', $this->root);
return Utils::replaceFirstOccurrence($this->base, '', $this->root);
}
/**
@ -541,7 +541,9 @@ class Uri
*/
public function currentPage()
{
return $this->params['page'] ?? 1;
$page = (int)($this->params['page'] ?? 1);
return max(1, $page);
}
/**
@ -783,7 +785,7 @@ class Uri
}
// special check to see if path checking is required.
$just_path = str_replace($normalized_url, '', $normalized_path);
$just_path = Utils::replaceFirstOccurrence($normalized_url, '', $normalized_path);
if ($normalized_url === '/' || $just_path === $page->path()) {
$url_path = $normalized_url;
} else {
@ -852,7 +854,7 @@ class Uri
}
// strip base from this path
$target_path = str_replace($uri->rootUrl(), '', $target_path);
$target_path = Utils::replaceFirstOccurrence($uri->rootUrl(), '', $target_path);
// set to / if root
if (empty($target_path)) {
@ -877,7 +879,7 @@ class Uri
// Handle route only
if ($route_only) {
$url_path = str_replace(static::filterPath($base_url), '', $url_path);
$url_path = Utils::replaceFirstOccurrence(static::filterPath($base_url), '', $url_path);
}
// transform back to string/array as needed
@ -998,7 +1000,7 @@ class Uri
}
// special check to see if path checking is required.
$just_path = str_replace($normalized_url, '', $normalized_path);
$just_path = Utils::replaceFirstOccurrence($normalized_url, '', $normalized_path);
if ($just_path === $page->path()) {
return $normalized_url;
}

141
system/src/Grav/Console/ConsoleCommand.php

@ -10,6 +10,10 @@
namespace Grav\Console;
use Grav\Common\Grav;
use Grav\Common\Language\Language;
use Grav\Common\Page\Page;
use Grav\Common\Processors\InitializeProcessor;
use RocketTheme\Toolbox\Event\Event;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -18,6 +22,13 @@ class ConsoleCommand extends Command
{
use ConsoleTrait;
/** @var bool */
private $plugins_initialized = false;
/** @var bool */
private $themes_initialized = false;
/** @var bool */
private $pages_initialized = false;
/**
* @param InputInterface $input
* @param OutputInterface $output
@ -31,12 +42,140 @@ class ConsoleCommand extends Command
}
/**
*
* Override with your implementation.
*/
protected function serve()
{
}
/**
* Initialize Grav.
*
* - Load configuration
* - Disable debugger
* - Set timezone, locale
* - Load plugins
* - Set Users type to be used in the site
*
* Safe to be called multiple times.
*
* @return $this
*/
final protected function initializeGrav()
{
InitializeProcessor::initializeCli(Grav::instance());
return $this;
}
/**
* Set language to be used in CLI.
*
* @param string|null $code
*/
final protected function setLanguage(string $code = null)
{
$this->initializeGrav();
$grav = Grav::instance();
/** @var Language $language */
$language = $grav['language'];
if ($language->enabled()) {
if ($code && $language->validate($code)) {
$language->setActive($code);
} else {
$language->setActive($language->getDefault());
}
}
}
/**
* Properly initialize plugins.
*
* - call $this->initializeGrav()
* - call onPluginsInitialized event
*
* Safe to be called multiple times.
*
* @return $this
*/
final protected function initializePlugins()
{
if (!$this->plugins_initialized) {
$this->plugins_initialized = true;
$this->initializeGrav();
// Initialize plugins.
$grav = Grav::instance();
$grav->fireEvent('onPluginsInitialized');
}
return $this;
}
/**
* Properly initialize themes.
*
* - call $this->initializePlugins()
* - initialize theme (call onThemeInitialized event)
*
* Safe to be called multiple times.
*
* @return $this
*/
final protected function initializeThemes()
{
if (!$this->themes_initialized) {
$this->themes_initialized = true;
$this->initializePlugins();
// Initialize themes.
$grav = Grav::instance();
$grav['themes']->init();
}
return $this;
}
/**
* Properly initialize pages.
*
* - call $this->initializeThemes()
* - initialize assets (call onAssetsInitialized event)
* - initialize twig (calls the twig events)
* - initialize pages (calls onPagesInitialized event)
*
* Safe to be called multiple times.
*
* @return $this
*/
final protected function initializePages()
{
if (!$this->pages_initialized) {
$this->pages_initialized = true;
$this->initializeThemes();
$grav = Grav::instance();
// Initialize assets.
$grav['assets']->init();
$grav->fireEvent('onAssetsInitialized');
// Initialize twig.
$grav['twig']->init();
// Initialize pages.
$pages = $grav['pages'];
$pages->init();
$grav->fireEvent('onPagesInitialized', new Event(['pages' => $pages]));
}
return $this;
}
protected function displayGPMRelease()
{
$this->output->writeln('');

54
system/src/Grav/Framework/Session/Session.php

@ -9,6 +9,7 @@
namespace Grav\Framework\Session;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Framework\Session\Exceptions\SessionException;
/**
@ -17,16 +18,13 @@ use Grav\Framework\Session\Exceptions\SessionException;
*/
class Session implements SessionInterface
{
protected $options;
/** @var array */
protected $options = [];
/**
* @var bool
*/
/** @var bool */
protected $started = false;
/**
* @var Session
*/
/** @var Session */
protected static $instance;
/**
@ -178,9 +176,13 @@ class Session implements SessionInterface
return $this;
}
$sessionName = session_name();
$sessionExists = isset($_COOKIE[$sessionName]);
// Protection against invalid session cookie names throwing exception: http://php.net/manual/en/function.session-id.php#116836
if (isset($_COOKIE[session_name()]) && !preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $_COOKIE[session_name()])) {
unset($_COOKIE[session_name()]);
if ($sessionExists && !preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $_COOKIE[$sessionName])) {
unset($_COOKIE[$sessionName]);
$sessionExists = false;
}
$options = $this->options;
@ -197,24 +199,28 @@ class Session implements SessionInterface
throw new SessionException('Failed to start session: ' . $error, 500);
}
if ($user && !$user->isValid()) {
$this->clear();
throw new SessionException('User Invalid', 500);
}
$this->started = true;
$params = session_get_cookie_params();
if ($user && (!$user instanceof UserInterface || !$user->isValid())) {
$this->invalidate();
setcookie(
session_name(),
session_id(),
time() + $params['lifetime'],
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
throw new SessionException('Invalid User object, session destroyed.', 500);
}
$this->started = true;
// Extend the lifetime of the session.
if ($sessionExists) {
$params = session_get_cookie_params();
setcookie(
$sessionName,
session_id(),
time() + $params['lifetime'],
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
}
return $this;
}

2
vendor/autoload.php vendored

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit90eaf9f321cf7eeb9a0f4360824deacb::getLoader();
return ComposerAutoloaderInitbfadb17c8b32495d4a707218d16cbd30::getLoader();

4
vendor/behat/gherkin/.gitignore vendored

@ -1,4 +0,0 @@
*.tgz
vendor
composer.phar
composer.lock

33
vendor/behat/gherkin/.travis.yml vendored

@ -1,33 +0,0 @@
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
php: [5.6, 7.0, 7.1, 7.2, 7.2]
matrix:
include:
- php: 5.6
env: SYMFONY_VERSION='2.3.*'
- php: 5.6
env: SYMFONY_VERSION='2.7.*'
- php: 5.6
env: SYMFONY_VERSION='2.8.*'
- php: 7.1
env: SYMFONY_VERSION='3.*'
before_install:
- composer self-update
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/yaml=$SYMFONY_VERSION; fi;
install:
- composer install
script: vendor/bin/phpunit -v --coverage-clover=coverage.clover
after_script:
# don't upload coverage on PHP 7 and HHVM as it cannot be generated. We don't want to tell Scrutinizer that the coverage generation failed.
- if [[ "7.0" != "$TRAVIS_PHP_VERSION" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

388
vendor/behat/gherkin/CHANGES.md vendored

@ -1,388 +0,0 @@
4.6.0 / 2019-01-16
==================
* Updated translations (including 'Example' as synonym for 'Scenario' in `en`)
4.5.1 / 2017-08-30
==================
* Fix regression in `PathsFilter`
4.5.0 / 2017-08-30
==================
* Sync i18n with Cucumber Gherkin
* Drop support for HHVM tests on Travis
* Add `TableNode::fromList()` method (thanks @TravisCarden)
* Add `ExampleNode::getOutlineTitle()` method (thanks @duxet)
* Use realpath, so the feature receives the cwd prefixed (thanks @glennunipro)
* Explicitly handle non-two-dimensional arrays in TableNode (thanks @TravisCarden)
* Fix to line/linefilter scenario runs which take relative paths to files (thanks @generalconsensus)
4.4.5 / 2016-10-30
==================
* Fix partial paths matching in `PathsFilter`
4.4.4 / 2016-09-18
==================
* Provide clearer exception for non-writeable cache directories
4.4.3 / 2016-09-18
==================
* Ensure we reset tags between features
4.4.2 / 2016-09-03
==================
* Sync 18n with gherkin 3
4.4.1 / 2015-12-30
==================
* Ensure keywords are trimmed when syncing translations
* Sync 18n with cucumber
4.4.0 / 2015-09-19
==================
* Added validation enforcing that all rows of a `TableNode` have the same number of columns
* Added `TableNode::getColumn` to get a column from the table
* Sync 18n with cucumber
4.3.0 / 2014-06-06
==================
* Added `setFilters(array)` method to `Gherkin` class
* Added `NarrativeFilter` for non-english `RoleFilter` lovers
4.2.1 / 2014-06-06
==================
* Fix parsing of features without line feed at the end
4.2.0 / 2014-05-27
==================
* Added `getKeyword()` and `getKeywordType()` methods to `StepNode`, deprecated `getType()`.
Thanks to @kibao
4.1.3 / 2014-05-25
==================
* Properly handle tables with rows terminating in whitespace
4.1.2 / 2014-05-14
==================
* Handle case where Gherkin cache is broken
4.1.1 / 2014-05-05
==================
* Fixed the compatibility with PHP 5.6-beta by avoiding to use the broken PHP array function
* The YamlFileLoader no longer extend from ArrayLoader but from AbstractFileLoader
4.1.0 / 2014-04-20
==================
* Fixed scenario tag filtering
* Do not allow multiple multiline step arguments
* Sync 18n with cucumber
4.0.0 / 2014-01-05
==================
* Changed the behavior when no loader can be found for the resource. Instead of throwing an exception, the
Gherkin class now returns an empty array.
3.1.3 / 2014-01-04
==================
* Dropped the dependency on the Symfony Finder by using SPL iterators directly
* Added testing on HHVM on Travis. HHVM is officially supported (previous release was actually already compatible)
3.1.2 / 2014-01-01
==================
* All paths passed to PathsFilter are converted using realpath
3.1.1 / 2013-12-31
==================
* Add `ComplexFilterInterace` that has complex behavior for scenarios and requires to pass
feature too
* `TagFilter` is an instance of a `ComplexFilterInterace` now
3.1.0 / 2013-12-31
==================
* Example node is a scenario
* Nodes do not have uprefs (memory usage fix)
* Scenario filters do not depend on feature nodes
3.0.5 / 2014-01-01
==================
* All paths passed to PathsFilter are converted using realpath
3.0.4 / 2013-12-31
==================
* TableNode is now traversable using foreach
* All possibly thrown exceptions implement Gherkin\Exception interface
* Sync i18n with cucumber
3.0.3 / 2013-09-15
==================
* Extend ExampleNode with additional methods
3.0.2 / 2013-09-14
==================
* Extract `KeywordNodeInterface` and `ScenarioLikeInterface`
* Add `getIndex()` methods to scenarios, outlines, steps and examples
* Throw proper exception for fractured node tree
3.0.1 / 2013-09-14
==================
* Use versioned subfolder in FileCache
3.0.0 / 2013-09-14
==================
* A lot of optimizations in Parser and Lexer
* Node tree is now immutable by nature (no setters)
* Example nodes are now part of the node tree. They are lazily generated by Outline node
* Sync with latest cucumber i18n
2.3.4 / 2013-08-11
==================
* Fix leaks in memory cache
2.3.3 / 2013-08-11
==================
* Fix encoding bug introduced with previous release
* Sync i18n with cucumber
2.3.2 / 2013-08-11
==================
* Explicitly use utf8 encoding
2.3.1 / 2013-08-10
==================
* Support `an` prefix with RoleFilter
2.3.0 / 2013-08-04
==================
* Add RoleFilter
* Add PathsFilter
* Add MemoryCache
2.2.9 / 2013-03-02
==================
* Fix dependency version requirement
2.2.8 / 2013-03-02
==================
* Features filtering behavior change. Now emptified (by filtering) features
that do not match filter themselves are removed from resultset.
* Small potential bug fix in TableNode
2.2.7 / 2013-01-27
==================
* Fixed bug in i18n syncing script
* Resynced Gherkin i18n
2.2.6 / 2013-01-26
==================
* Support long row hashes in tables ([see](https://github.com/Behat/Gherkin/issues/40))
* Synced Gherkin i18n
2.2.5 / 2012-09-26
==================
* Fixed issue with loading empty features
* Synced Gherkin i18n
2.2.4 / 2012-08-03
==================
* Fixed exception message for "no loader found"
2.2.3 / 2012-08-03
==================
* Fixed minor loader bug with empty base path
* Synced Gherkin i18n
2.2.2 / 2012-07-01
==================
* Added ability to filter outline scenarios by line and range filters
* Synced Gherkin i18n
* Refactored table parser to read row line numbers too
2.2.1 / 2012-05-04
==================
* Fixed StepNode `getLanguage()` and `getFile()`
2.2.0 / 2012-05-03
==================
* Features freeze after parsing
* Implemented GherkinDumper (@Halleck45)
* Synced i18n with Cucumber
* Updated inline documentation
2.1.1 / 2012-03-09
==================
* Fixed caching bug, where `isFresh()` always returned false
2.1.0 / 2012-03-09
==================
* Added parser caching layer
* Added support for table delimiter escaping (use `\|` for that)
* Added LineRangeFilter (thanks @headrevision)
* Synced i18n dictionary with cucumber/gherkin
2.0.2 / 2012-02-04
==================
* Synced i18n dictionary with cucumber/gherkin
2.0.1 / 2012-01-26
==================
* Fixed issue about parsing features without indentation
2.0.0 / 2012-01-19
==================
* Background titles support
* Correct parsing of titles/descriptions (hirarchy lexing)
* Migration to the cucumber/gherkin i18n dictionary
* Speed optimizations
* Refactored KeywordsDumper
* New loaders
* Bugfixes
1.1.4 / 2012-01-08
==================
* Read feature description even if it looks like a step
1.1.3 / 2011-12-14
==================
* Removed file loading routines from Parser (fixes `is_file()` issue on some systems - thanks
@flodocteurklein)
1.1.2 / 2011-12-01
==================
* Updated spanish trasnaltion (@anbotero)
* Integration with Composer and Travis CI
1.1.1 / 2011-07-29
==================
* Updated pt language step types (@danielcsgomes)
* Updated vendors
1.1.0 / 2011-07-16
==================
* Return all tags, including inherited in `Scenario::getTags()`
* New `Feature::getOwnTags()` and `Scenario::getOwnTags()` method added,
which returns only own tags
1.0.8 / 2011-06-29
==================
* Fixed comments parsing.
You can’t have comments at the end of a line # like this
# But you can still have comments at the beginning of a line
1.0.7 / 2011-06-28
==================
* Added `getRaw()` method to PyStringNode
* Updated vendors
1.0.6 / 2011-06-17
==================
* Updated vendors
1.0.5 / 2011-06-10
==================
* Fixed bug, introduced with 1.0.4 - hash in PyStrings
1.0.4 / 2011-06-10
==================
* Fixed inability to comment pystrings
1.0.3 / 2011-04-21
==================
* Fixed introduced with 1.0.2 pystring parsing bug
1.0.2 / 2011-04-18
==================
* Fixed bugs in text with comments parsing
1.0.1 / 2011-04-01
==================
* Updated vendors
1.0.0 / 2011-03-08
==================
* Updated vendors
1.0.0RC2 / 2011-02-25
=====================
* Windows support
* Missing phpunit config
1.0.0RC1 / 2011-02-15
=====================
* Huge optimizations to Lexer & Parser
* Additional loaders (Yaml, Array, Directory)
* Filters (Tag, Name, Line)
* Code refactoring
* Nodes optimizations
* Additional tests for exceptions and translations
* Keywords dumper
0.2.0 / 2011-01-05
==================
* New Parser & Lexer (based on AST)
* New verbose parsing exception handling
* New translation mechanics
* 47 brand new translations (see i18n)
* Full test suite for everything from AST nodes to translations

33
vendor/behat/gherkin/CONTRIBUTING.md vendored

@ -1,33 +0,0 @@
Contributing
------------
Gherkin is an open source, community-driven project. If you'd like to contribute, feel free to do this, but remember to follow this few simple rules:
- Make your feature addition or bug fix,
- Always use the `master` branch as base for your changes (all new development happens in `master`),
- Add tests for those changes (please look into `tests/` folder for some examples). This is important so we don't break it in a future version unintentionally,
- Commit your code, but do not mess with `CHANGES.md`,
- __Remember__: when you create Pull Request, always select `master` branch as target (done by default), otherwise it will be closed.
Running tests
-------------
Make sure that you don't break anything with your changes by running:
```bash
$> phpunit
```
Contributing to Gherkin Translations
------------------------------------
Gherkin supports &rarr;40 different languages and you could add more! You might notice
`i18n.php` file in the root of the library. This file is downloaded and **autogenerated**
from original [cucumber/gherkin translations](https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json).
So, in order to fix/update/add some translation, you should send Pull Request to the
`cucumber/gherkin` repository. `Behat\Gherkin` will redownload/regenerate translations
from there before each release.
It might sounds difficult, but this way of dictionary sharing gives you ability to
migrate your `*.feature` files from language to language and library to library without
the need to rewrite/modify them - same dictionary (Gherkin) used everywhere.

22
vendor/behat/gherkin/LICENSE vendored

@ -1,22 +0,0 @@
Copyright (c) 2011-2013 Konstantin Kudryashov <ever.zet@gmail.com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

68
vendor/behat/gherkin/README.md vendored

@ -1,68 +0,0 @@
Behat Gherkin Parser
====================
This is the php Gherkin parser for Behat. It comes bundled with more than 40 native languages
(see `i18n.php`) support & clean architecture.
[![Build Status](https://travis-ci.org/Behat/Gherkin.svg?branch=master)](https://travis-ci.org/Behat/Gherkin)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Behat/Gherkin/badges/quality-score.png?s=04d9d0237c89f4c45a94ba5304234db861dfd036)](https://scrutinizer-ci.com/g/Behat/Gherkin/)
[![Code Coverage](https://scrutinizer-ci.com/g/Behat/Gherkin/badges/coverage.png?s=204ca44800469d295b73d18c91011cb9d2dc99fc)](https://scrutinizer-ci.com/g/Behat/Gherkin/)
Useful Links
------------
- Official Google Group is at [http://groups.google.com/group/behat](http://groups.google.com/group/behat)
- IRC channel on [#freenode](http://freenode.net/) is `#behat`
- [Note on Patches/Pull Requests](CONTRIBUTING.md)
Usage Example
-------------
``` php
<?php
$keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array(
'en' => array(
'feature' => 'Feature',
'background' => 'Background',
'scenario' => 'Scenario',
'scenario_outline' => 'Scenario Outline|Scenario Template',
'examples' => 'Examples|Scenarios',
'given' => 'Given',
'when' => 'When',
'then' => 'Then',
'and' => 'And',
'but' => 'But'
),
'en-pirate' => array(
'feature' => 'Ahoy matey!',
'background' => 'Yo-ho-ho',
'scenario' => 'Heave to',
'scenario_outline' => 'Shiver me timbers',
'examples' => 'Dead men tell no tales',
'given' => 'Gangway!',
'when' => 'Blimey!',
'then' => 'Let go and haul',
'and' => 'Aye',
'but' => 'Avast!'
)
));
$lexer = new Behat\Gherkin\Lexer($keywords);
$parser = new Behat\Gherkin\Parser($lexer);
$feature = $parser->parse(file_get_contents('some.feature'));
```
Installing Dependencies
-----------------------
``` bash
$> curl http://getcomposer.org/installer | php
$> php composer.phar update
```
Contributors
------------
* Konstantin Kudryashov [everzet](http://github.com/everzet) [lead developer]
* Other [awesome developers](https://github.com/Behat/Gherkin/graphs/contributors)

70
vendor/behat/gherkin/bin/update_i18n vendored

@ -1,70 +0,0 @@
#!/usr/bin/env php
<?php
$gherkinUrl = 'https://raw.githubusercontent.com/cucumber/cucumber/master/gherkin/gherkin-languages.json';
$json = file_get_contents($gherkinUrl);
$array = array();
foreach (json_decode($json, true) as $lang => $keywords) {
$langMessages = array();
foreach ($keywords as $type => $words) {
if (!is_array($words)) {
$words = array($words);
}
if ('scenarioOutline' === $type) {
$type = 'scenario_outline';
}
if (in_array($type, array('given', 'when', 'then', 'and', 'but'))) {
$formattedKeywords = array();
foreach ($words as $word) {
$formattedWord = trim($word);
if ($formattedWord === $word) {
$formattedWord = $formattedWord.'<'; // Convert the keywords to the syntax used by Gherkin 2, which is expected by our Lexer.
}
$formattedKeywords[] = $formattedWord;
}
$words = $formattedKeywords;
}
usort($words, function($type1, $type2) {
return mb_strlen($type2, 'utf8') - mb_strlen($type1, 'utf8');
});
$langMessages[$type] = implode('|', $words);
}
// ensure that the order of keys is consistent between updates
ksort($langMessages);
$array[$lang] = $langMessages;
}
// ensure that the languages are sorted to avoid useless diffs between updates. We keep the English first though as it is the reference.
$enData = $array['en'];
unset($array['en']);
ksort($array);
$array = array_merge(array('en' => $enData), $array);
$arrayString = var_export($array, true);
file_put_contents(__DIR__.'/../i18n.php', <<<EOD
<?php
/*
* DO NOT TOUCH THIS FILE!
*
* This file is automatically generated by `bin/update_i18n`.
* Actual Gherkin translations live in cucumber/gherkin repo:
* {$gherkinUrl}
* Please send your translation changes there.
*/
return $arrayString;
EOD
);

47
vendor/behat/gherkin/composer.json vendored

@ -1,47 +0,0 @@
{
"name": "behat/gherkin",
"description": "Gherkin DSL parser for PHP 5.3",
"keywords": ["BDD", "parser", "DSL", "Behat", "Gherkin", "Cucumber"],
"homepage": "http://behat.org/",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
}
],
"require": {
"php": ">=5.3.1"
},
"require-dev": {
"symfony/yaml": "~2.3|~3|~4",
"symfony/phpunit-bridge": "~2.7|~3|~4",
"phpunit/phpunit": "~4.5|~5"
},
"suggest": {
"symfony/yaml": "If you want to parse features, represented in YAML files"
},
"autoload": {
"psr-0": {
"Behat\\Gherkin": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Behat\\": "tests/Behat/"
}
},
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
}
}

1197
vendor/behat/gherkin/i18n.php vendored

File diff suppressed because it is too large Load Diff

3
vendor/behat/gherkin/libpath.php vendored

@ -1,3 +0,0 @@
<?php
return __DIR__;

71
vendor/behat/gherkin/package.xml.tpl vendored

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.8.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
<name>gherkin</name>
<channel>pear.behat.org</channel>
<summary>Behat\Gherkin is a BDD DSL for PHP</summary>
<description>
Behat\Gherkin is an open source behavior driven development DSL for php 5.3.
</description>
<lead>
<name>Konstantin Kudryashov</name>
<user>everzet</user>
<email>ever.zet@gmail.com</email>
<active>yes</active>
</lead>
<date>##CURRENT_DATE##</date>
<version>
<release>##GHERKIN_VERSION##</release>
<api>1.0.0</api>
</version>
<stability>
<release>##STABILITY##</release>
<api>##STABILITY##</api>
</stability>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT</license>
<notes>-</notes>
<contents>
<dir name="/">
##SOURCE_FILES##
<file role="php" baseinstalldir="gherkin" name="autoload.php" />
<file role="php" baseinstalldir="gherkin" name="libpath.php" />
<file role="php" baseinstalldir="gherkin" name="i18n.php" />
<file role="php" baseinstalldir="gherkin" name="vendor/.composer/autoload.php" />
<file role="php" baseinstalldir="gherkin" name="vendor/.composer/autoload_namespaces.php" />
<file role="php" baseinstalldir="gherkin" name="phpdoc.ini.dist" />
<file role="php" baseinstalldir="gherkin" name="phpunit.xml.dist" />
<file role="php" baseinstalldir="gherkin" name="CHANGES.md" />
<file role="php" baseinstalldir="gherkin" name="LICENSE" />
<file role="php" baseinstalldir="gherkin" name="README.md" />
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.3.1</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
<extension>
<name>pcre</name>
</extension>
<extension>
<name>simplexml</name>
</extension>
<extension>
<name>xml</name>
</extension>
<extension>
<name>mbstring</name>
</extension>
</required>
</dependencies>
<phprelease />
</package>

14
vendor/behat/gherkin/phpdoc.ini.dist vendored

@ -1,14 +0,0 @@
files = "*.php"
ignore = "CVS, .svn, .git, _compiled"
source_path = "./src"
doclet = standard
overview = readme.html
package_comment_dir = ./
public = on
d = "api"
default_package = "Behat Gherkin"
windowtitle = "Behat Gherkin"
doctitle = "Behat Gherkin: PHP 5.3 Gherkin parser"
header = "Behat Gherkin"
footer = "Behat Gherkin"
tree = on

25
vendor/behat/gherkin/phpunit.xml.dist vendored

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Behat Gherkin test suite">
<directory>./tests/Behat/Gherkin/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/Behat/Gherkin/</directory>
</whitelist>
</filter>
</phpunit>

48
vendor/behat/gherkin/src/Behat/Gherkin/Cache/CacheInterface.php vendored

@ -1,48 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Cache;
use Behat\Gherkin\Node\FeatureNode;
/**
* Parser cache interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface CacheInterface
{
/**
* Checks that cache for feature exists and is fresh.
*
* @param string $path Feature path
* @param integer $timestamp The last time feature was updated
*
* @return Boolean
*/
public function isFresh($path, $timestamp);
/**
* Reads feature cache from path.
*
* @param string $path Feature path
*
* @return FeatureNode
*/
public function read($path);
/**
* Caches feature node.
*
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
public function write($path, FeatureNode $feature);
}

109
vendor/behat/gherkin/src/Behat/Gherkin/Cache/FileCache.php vendored

@ -1,109 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Cache;
use Behat\Gherkin\Exception\CacheException;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Gherkin;
/**
* File cache.
* Caches feature into a file.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class FileCache implements CacheInterface
{
private $path;
/**
* Initializes file cache.
*
* @param string $path Path to the folder where to store caches.
*
* @throws CacheException
*/
public function __construct($path)
{
$this->path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'v'.Gherkin::VERSION;
if (!is_dir($this->path)) {
@mkdir($this->path, 0777, true);
}
if (!is_writeable($this->path)) {
throw new CacheException(sprintf('Cache path "%s" is not writeable. Check your filesystem permissions or disable Gherkin file cache.', $this->path));
}
}
/**
* Checks that cache for feature exists and is fresh.
*
* @param string $path Feature path
* @param integer $timestamp The last time feature was updated
*
* @return Boolean
*/
public function isFresh($path, $timestamp)
{
$cachePath = $this->getCachePathFor($path);
if (!file_exists($cachePath)) {
return false;
}
return filemtime($cachePath) > $timestamp;
}
/**
* Reads feature cache from path.
*
* @param string $path Feature path
*
* @return FeatureNode
*
* @throws CacheException
*/
public function read($path)
{
$cachePath = $this->getCachePathFor($path);
$feature = unserialize(file_get_contents($cachePath));
if (!$feature instanceof FeatureNode) {
throw new CacheException(sprintf('Can not load cache for a feature "%s" from "%s".', $path, $cachePath ));
}
return $feature;
}
/**
* Caches feature node.
*
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
public function write($path, FeatureNode $feature)
{
file_put_contents($this->getCachePathFor($path), serialize($feature));
}
/**
* Returns feature cache file path from features path.
*
* @param string $path Feature path
*
* @return string
*/
protected function getCachePathFor($path)
{
return $this->path.'/'.md5($path).'.feature.cache';
}
}

66
vendor/behat/gherkin/src/Behat/Gherkin/Cache/MemoryCache.php vendored

@ -1,66 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Cache;
use Behat\Gherkin\Node\FeatureNode;
/**
* Memory cache.
* Caches feature into a memory.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class MemoryCache implements CacheInterface
{
private $features = array();
private $timestamps = array();
/**
* Checks that cache for feature exists and is fresh.
*
* @param string $path Feature path
* @param integer $timestamp The last time feature was updated
*
* @return Boolean
*/
public function isFresh($path, $timestamp)
{
if (!isset($this->features[$path])) {
return false;
}
return $this->timestamps[$path] > $timestamp;
}
/**
* Reads feature cache from path.
*
* @param string $path Feature path
*
* @return FeatureNode
*/
public function read($path)
{
return $this->features[$path];
}
/**
* Caches feature node.
*
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
public function write($path, FeatureNode $feature)
{
$this->features[$path] = $feature;
$this->timestamps[$path] = time();
}
}

22
vendor/behat/gherkin/src/Behat/Gherkin/Exception/CacheException.php vendored

@ -1,22 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Exception;
use RuntimeException;
/**
* Cache exception.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class CacheException extends RuntimeException implements Exception
{
}

15
vendor/behat/gherkin/src/Behat/Gherkin/Exception/Exception.php vendored

@ -1,15 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Exception;
interface Exception
{
}

17
vendor/behat/gherkin/src/Behat/Gherkin/Exception/LexerException.php vendored

@ -1,17 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Exception;
use RuntimeException;
class LexerException extends RuntimeException implements Exception
{
}

17
vendor/behat/gherkin/src/Behat/Gherkin/Exception/NodeException.php vendored

@ -1,17 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Exception;
use RuntimeException;
class NodeException extends RuntimeException implements Exception
{
}

17
vendor/behat/gherkin/src/Behat/Gherkin/Exception/ParserException.php vendored

@ -1,17 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Exception;
use RuntimeException;
class ParserException extends RuntimeException implements Exception
{
}

52
vendor/behat/gherkin/src/Behat/Gherkin/Filter/ComplexFilter.php vendored

@ -1,52 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
/**
* Abstract filter class.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
abstract class ComplexFilter implements ComplexFilterInterface
{
/**
* Filters feature according to the filter.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
$scenarios = array();
foreach ($feature->getScenarios() as $scenario) {
if (!$this->isScenarioMatch($feature, $scenario)) {
continue;
}
$scenarios[] = $scenario;
}
return new FeatureNode(
$feature->getTitle(),
$feature->getDescription(),
$feature->getTags(),
$feature->getBackground(),
$scenarios,
$feature->getKeyword(),
$feature->getLanguage(),
$feature->getFile(),
$feature->getLine()
);
}
}

32
vendor/behat/gherkin/src/Behat/Gherkin/Filter/ComplexFilterInterface.php vendored

@ -1,32 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filter interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface ComplexFilterInterface extends FeatureFilterInterface
{
/**
* Checks if scenario or outline matches specified filter.
*
* @param FeatureNode $feature Feature node instance
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(FeatureNode $feature, ScenarioInterface $scenario);
}

39
vendor/behat/gherkin/src/Behat/Gherkin/Filter/FeatureFilterInterface.php vendored

@ -1,39 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
/**
* Feature filter interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface FeatureFilterInterface
{
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature);
/**
* Filters feature according to the filter and returns new one.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature);
}

30
vendor/behat/gherkin/src/Behat/Gherkin/Filter/FilterInterface.php vendored

@ -1,30 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filter interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface FilterInterface extends FeatureFilterInterface
{
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(ScenarioInterface $scenario);
}

122
vendor/behat/gherkin/src/Behat/Gherkin/Filter/LineFilter.php vendored

@ -1,122 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\OutlineNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filters scenarios by definition line number.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class LineFilter implements FilterInterface
{
protected $filterLine;
/**
* Initializes filter.
*
* @param string $filterLine Line of the scenario to filter on
*/
public function __construct($filterLine)
{
$this->filterLine = intval($filterLine);
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
return $this->filterLine === $feature->getLine();
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
if ($this->filterLine === $scenario->getLine()) {
return true;
}
if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
return $this->filterLine === $scenario->getLine()
|| in_array($this->filterLine, $scenario->getExampleTable()->getLines());
}
return false;
}
/**
* Filters feature according to the filter and returns new one.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
$scenarios = array();
foreach ($feature->getScenarios() as $scenario) {
if (!$this->isScenarioMatch($scenario)) {
continue;
}
if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
$table = $scenario->getExampleTable()->getTable();
$lines = array_keys($table);
if (in_array($this->filterLine, $lines)) {
$filteredTable = array($lines[0] => $table[$lines[0]]);
if ($lines[0] !== $this->filterLine) {
$filteredTable[$this->filterLine] = $table[$this->filterLine];
}
$scenario = new OutlineNode(
$scenario->getTitle(),
$scenario->getTags(),
$scenario->getSteps(),
new ExampleTableNode($filteredTable, $scenario->getExampleTable()->getKeyword()),
$scenario->getKeyword(),
$scenario->getLine()
);
}
}
$scenarios[] = $scenario;
}
return new FeatureNode(
$feature->getTitle(),
$feature->getDescription(),
$feature->getTags(),
$feature->getBackground(),
$scenarios,
$feature->getKeyword(),
$feature->getLanguage(),
$feature->getFile(),
$feature->getLine()
);
}
}

134
vendor/behat/gherkin/src/Behat/Gherkin/Filter/LineRangeFilter.php vendored

@ -1,134 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\OutlineNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filters scenarios by definition line number range.
*
* @author Fabian Kiss <headrevision@gmail.com>
*/
class LineRangeFilter implements FilterInterface
{
protected $filterMinLine;
protected $filterMaxLine;
/**
* Initializes filter.
*
* @param string $filterMinLine Minimum line of a scenario to filter on
* @param string $filterMaxLine Maximum line of a scenario to filter on
*/
public function __construct($filterMinLine, $filterMaxLine)
{
$this->filterMinLine = intval($filterMinLine);
if ($filterMaxLine == '*') {
$this->filterMaxLine = PHP_INT_MAX;
} else {
$this->filterMaxLine = intval($filterMaxLine);
}
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
return $this->filterMinLine <= $feature->getLine()
&& $this->filterMaxLine >= $feature->getLine();
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
if ($this->filterMinLine <= $scenario->getLine() && $this->filterMaxLine >= $scenario->getLine()) {
return true;
}
if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
foreach ($scenario->getExampleTable()->getLines() as $line) {
if ($this->filterMinLine <= $line && $this->filterMaxLine >= $line) {
return true;
}
}
}
return false;
}
/**
* Filters feature according to the filter.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
$scenarios = array();
foreach ($feature->getScenarios() as $scenario) {
if (!$this->isScenarioMatch($scenario)) {
continue;
}
if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
$table = $scenario->getExampleTable()->getTable();
$lines = array_keys($table);
$filteredTable = array($lines[0] => $table[$lines[0]]);
unset($table[$lines[0]]);
foreach ($table as $line => $row) {
if ($this->filterMinLine <= $line && $this->filterMaxLine >= $line) {
$filteredTable[$line] = $row;
}
}
$scenario = new OutlineNode(
$scenario->getTitle(),
$scenario->getTags(),
$scenario->getSteps(),
new ExampleTableNode($filteredTable, $scenario->getExampleTable()->getKeyword()),
$scenario->getKeyword(),
$scenario->getLine()
);
}
$scenarios[] = $scenario;
}
return new FeatureNode(
$feature->getTitle(),
$feature->getDescription(),
$feature->getTags(),
$feature->getBackground(),
$scenarios,
$feature->getKeyword(),
$feature->getLanguage(),
$feature->getFile(),
$feature->getLine()
);
}
}

68
vendor/behat/gherkin/src/Behat/Gherkin/Filter/NameFilter.php vendored

@ -1,68 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filters scenarios by feature/scenario name.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class NameFilter extends SimpleFilter
{
protected $filterString;
/**
* Initializes filter.
*
* @param string $filterString Name filter string
*/
public function __construct($filterString)
{
$this->filterString = trim($filterString);
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
if ('/' === $this->filterString[0]) {
return 1 === preg_match($this->filterString, $feature->getTitle());
}
return false !== mb_strpos($feature->getTitle(), $this->filterString, 0, 'utf8');
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
if ('/' === $this->filterString[0] && 1 === preg_match($this->filterString, $scenario->getTitle())) {
return true;
} elseif (false !== mb_strpos($scenario->getTitle(), $this->filterString, 0, 'utf8')) {
return true;
}
return false;
}
}

61
vendor/behat/gherkin/src/Behat/Gherkin/Filter/NarrativeFilter.php vendored

@ -1,61 +0,0 @@
<?php
/*
* This file is part of the Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\ScenarioInterface;
use Behat\Gherkin\Node\FeatureNode;
/**
* Filters features by their narrative using regular expression.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class NarrativeFilter extends SimpleFilter
{
/**
* @var string
*/
private $regex;
/**
* Initializes filter.
*
* @param string $regex
*/
public function __construct($regex)
{
$this->regex = $regex;
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
return 1 === preg_match($this->regex, $feature->getDescription());
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
return false;
}
}

72
vendor/behat/gherkin/src/Behat/Gherkin/Filter/PathsFilter.php vendored

@ -1,72 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filters features by their paths.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class PathsFilter extends SimpleFilter
{
protected $filterPaths = array();
/**
* Initializes filter.
*
* @param string[] $paths List of approved paths
*/
public function __construct(array $paths)
{
$this->filterPaths = array_map(
function ($realpath) {
return rtrim($realpath, DIRECTORY_SEPARATOR) .
(is_dir($realpath) ? DIRECTORY_SEPARATOR : '');
},
array_filter(
array_map('realpath', $paths)
)
);
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
foreach ($this->filterPaths as $path) {
if (0 === strpos(realpath($feature->getFile()), $path)) {
return true;
}
}
return false;
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return false This filter is designed to work only with features
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
return false;
}
}

63
vendor/behat/gherkin/src/Behat/Gherkin/Filter/RoleFilter.php vendored

@ -1,63 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filters features by their actors role.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class RoleFilter extends SimpleFilter
{
protected $pattern;
/**
* Initializes filter.
*
* @param string $role Approved role wildcard
*/
public function __construct($role)
{
$this->pattern = '/as an? ' . strtr(preg_quote($role, '/'), array(
'\*' => '.*',
'\?' => '.',
'\[' => '[',
'\]' => ']'
)) . '[$\n]/i';
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
return 1 === preg_match($this->pattern, $feature->getDescription());
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return false This filter is designed to work only with features
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
return false;
}
}

56
vendor/behat/gherkin/src/Behat/Gherkin/Filter/SimpleFilter.php vendored

@ -1,56 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
/**
* Abstract filter class.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
abstract class SimpleFilter implements FilterInterface
{
/**
* Filters feature according to the filter.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
if ($this->isFeatureMatch($feature)) {
return $feature;
}
$scenarios = array();
foreach ($feature->getScenarios() as $scenario) {
if (!$this->isScenarioMatch($scenario)) {
continue;
}
$scenarios[] = $scenario;
}
return new FeatureNode(
$feature->getTitle(),
$feature->getDescription(),
$feature->getTags(),
$feature->getBackground(),
$scenarios,
$feature->getKeyword(),
$feature->getLanguage(),
$feature->getFile(),
$feature->getLine()
);
}
}

90
vendor/behat/gherkin/src/Behat/Gherkin/Filter/TagFilter.php vendored

@ -1,90 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioInterface;
/**
* Filters scenarios by feature/scenario tag.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class TagFilter extends ComplexFilter
{
protected $filterString;
/**
* Initializes filter.
*
* @param string $filterString Name filter string
*/
public function __construct($filterString)
{
$this->filterString = trim($filterString);
}
/**
* Checks if Feature matches specified filter.
*
* @param FeatureNode $feature Feature instance
*
* @return Boolean
*/
public function isFeatureMatch(FeatureNode $feature)
{
return $this->isTagsMatchCondition($feature->getTags());
}
/**
* Checks if scenario or outline matches specified filter.
*
* @param FeatureNode $feature Feature node instance
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return Boolean
*/
public function isScenarioMatch(FeatureNode $feature, ScenarioInterface $scenario)
{
return $this->isTagsMatchCondition(array_merge($feature->getTags(), $scenario->getTags()));
}
/**
* Checks that node matches condition.
*
* @param string[] $tags
*
* @return Boolean
*/
protected function isTagsMatchCondition($tags)
{
$satisfies = true;
foreach (explode('&&', $this->filterString) as $andTags) {
$satisfiesComma = false;
foreach (explode(',', $andTags) as $tag) {
$tag = str_replace('@', '', trim($tag));
if ('~' === $tag[0]) {
$tag = mb_substr($tag, 1, mb_strlen($tag, 'utf8') - 1, 'utf8');
$satisfiesComma = !in_array($tag, $tags) || $satisfiesComma;
} else {
$satisfiesComma = in_array($tag, $tags) || $satisfiesComma;
}
}
$satisfies = (false !== $satisfiesComma && $satisfies && $satisfiesComma) || false;
}
return $satisfies;
}
}

142
vendor/behat/gherkin/src/Behat/Gherkin/Gherkin.php vendored

@ -1,142 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin;
use Behat\Gherkin\Filter\FeatureFilterInterface;
use Behat\Gherkin\Filter\LineFilter;
use Behat\Gherkin\Filter\LineRangeFilter;
use Behat\Gherkin\Loader\FileLoaderInterface;
use Behat\Gherkin\Loader\LoaderInterface;
/**
* Gherkin manager.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class Gherkin
{
const VERSION = '4.4-dev';
/**
* @var LoaderInterface[]
*/
protected $loaders = array();
/**
* @var FeatureFilterInterface[]
*/
protected $filters = array();
/**
* Adds loader to manager.
*
* @param LoaderInterface $loader Feature loader
*/
public function addLoader(LoaderInterface $loader)
{
$this->loaders[] = $loader;
}
/**
* Adds filter to manager.
*
* @param FeatureFilterInterface $filter Feature filter
*/
public function addFilter(FeatureFilterInterface $filter)
{
$this->filters[] = $filter;
}
/**
* Sets filters to the parser.
*
* @param FeatureFilterInterface[] $filters
*/
public function setFilters(array $filters)
{
$this->filters = array();
array_map(array($this, 'addFilter'), $filters);
}
/**
* Sets base features path.
*
* @param string $path Loaders base path
*/
public function setBasePath($path)
{
foreach ($this->loaders as $loader) {
if ($loader instanceof FileLoaderInterface) {
$loader->setBasePath($path);
}
}
}
/**
* Loads & filters resource with added loaders.
*
* @param mixed $resource Resource to load
* @param FeatureFilterInterface[] $filters Additional filters
*
* @return array
*/
public function load($resource, array $filters = array())
{
$filters = array_merge($this->filters, $filters);
$matches = array();
if (preg_match('/^(.*)\:(\d+)-(\d+|\*)$/', $resource, $matches)) {
$resource = $matches[1];
$filters[] = new LineRangeFilter($matches[2], $matches[3]);
} elseif (preg_match('/^(.*)\:(\d+)$/', $resource, $matches)) {
$resource = $matches[1];
$filters[] = new LineFilter($matches[2]);
}
$loader = $this->resolveLoader($resource);
if (null === $loader) {
return array();
}
$features = array();
foreach ($loader->load($resource) as $feature) {
foreach ($filters as $filter) {
$feature = $filter->filterFeature($feature);
if (!$feature->hasScenarios() && !$filter->isFeatureMatch($feature)) {
continue 2;
}
}
$features[] = $feature;
}
return $features;
}
/**
* Resolves loader by resource.
*
* @param mixed $resource Resource to load
*
* @return LoaderInterface
*/
public function resolveLoader($resource)
{
foreach ($this->loaders as $loader) {
if ($loader->supports($resource)) {
return $loader;
}
}
return null;
}
}

200
vendor/behat/gherkin/src/Behat/Gherkin/Keywords/ArrayKeywords.php vendored

@ -1,200 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Keywords;
/**
* Array initializable keywords holder.
*
* $keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array(
* 'en' => array(
* 'feature' => 'Feature',
* 'background' => 'Background',
* 'scenario' => 'Scenario',
* 'scenario_outline' => 'Scenario Outline|Scenario Template',
* 'examples' => 'Examples|Scenarios',
* 'given' => 'Given',
* 'when' => 'When',
* 'then' => 'Then',
* 'and' => 'And',
* 'but' => 'But'
* ),
* 'ru' => array(
* 'feature' => 'Функционал',
* 'background' => 'Предыстория',
* 'scenario' => 'Сценарий',
* 'scenario_outline' => 'Структура сценария',
* 'examples' => 'Примеры',
* 'given' => 'Допустим',
* 'when' => 'Если',
* 'then' => 'То',
* 'and' => 'И',
* 'but' => 'Но'
* )
* ));
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class ArrayKeywords implements KeywordsInterface
{
private $keywords = array();
private $keywordString = array();
private $language;
/**
* Initializes holder with keywords.
*
* @param array $keywords Keywords array
*/
public function __construct(array $keywords)
{
$this->keywords = $keywords;
}
/**
* Sets keywords holder language.
*
* @param string $language Language name
*/
public function setLanguage($language)
{
if (!isset($this->keywords[$language])) {
$this->language = 'en';
} else {
$this->language = $language;
}
}
/**
* Returns Feature keywords (splitted by "|").
*
* @return string
*/
public function getFeatureKeywords()
{
return $this->keywords[$this->language]['feature'];
}
/**
* Returns Background keywords (splitted by "|").
*
* @return string
*/
public function getBackgroundKeywords()
{
return $this->keywords[$this->language]['background'];
}
/**
* Returns Scenario keywords (splitted by "|").
*
* @return string
*/
public function getScenarioKeywords()
{
return $this->keywords[$this->language]['scenario'];
}
/**
* Returns Scenario Outline keywords (splitted by "|").
*
* @return string
*/
public function getOutlineKeywords()
{
return $this->keywords[$this->language]['scenario_outline'];
}
/**
* Returns Examples keywords (splitted by "|").
*
* @return string
*/
public function getExamplesKeywords()
{
return $this->keywords[$this->language]['examples'];
}
/**
* Returns Given keywords (splitted by "|").
*
* @return string
*/
public function getGivenKeywords()
{
return $this->keywords[$this->language]['given'];
}
/**
* Returns When keywords (splitted by "|").
*
* @return string
*/
public function getWhenKeywords()
{
return $this->keywords[$this->language]['when'];
}
/**
* Returns Then keywords (splitted by "|").
*
* @return string
*/
public function getThenKeywords()
{
return $this->keywords[$this->language]['then'];
}
/**
* Returns And keywords (splitted by "|").
*
* @return string
*/
public function getAndKeywords()
{
return $this->keywords[$this->language]['and'];
}
/**
* Returns But keywords (splitted by "|").
*
* @return string
*/
public function getButKeywords()
{
return $this->keywords[$this->language]['but'];
}
/**
* Returns all step keywords (Given, When, Then, And, But).
*
* @return string
*/
public function getStepKeywords()
{
if (!isset($this->keywordString[$this->language])) {
$keywords = array_merge(
explode('|', $this->getGivenKeywords()),
explode('|', $this->getWhenKeywords()),
explode('|', $this->getThenKeywords()),
explode('|', $this->getAndKeywords()),
explode('|', $this->getButKeywords())
);
usort($keywords, function ($keyword1, $keyword2) {
return mb_strlen($keyword2, 'utf8') - mb_strlen($keyword1, 'utf8');
});
$this->keywordString[$this->language] = implode('|', $keywords);
}
return $this->keywordString[$this->language];
}
}

31
vendor/behat/gherkin/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php vendored

@ -1,31 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Keywords;
/**
* File initializable keywords holder.
*
* $keywords = new Behat\Gherkin\Keywords\CachedArrayKeywords($file);
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class CachedArrayKeywords extends ArrayKeywords
{
/**
* Initializes holder with file.
*
* @param string $file Cached array path
*/
public function __construct($file)
{
parent::__construct(include($file));
}
}

121
vendor/behat/gherkin/src/Behat/Gherkin/Keywords/CucumberKeywords.php vendored

@ -1,121 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Keywords;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
/**
* Cucumber-translations reader.
*
* $keywords = new Behat\Gherkin\Keywords\CucumberKeywords($i18nYmlPath);
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class CucumberKeywords extends ArrayKeywords
{
/**
* Initializes holder with yaml string OR file.
*
* @param string $yaml Yaml string or file path
*/
public function __construct($yaml)
{
// Handle filename explicitly for BC reasons, as Symfony Yaml 3.0 does not do it anymore
$file = null;
if (strpos($yaml, "\n") === false && is_file($yaml)) {
if (false === is_readable($yaml)) {
throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $yaml));
}
$file = $yaml;
$yaml = file_get_contents($file);
}
try {
$content = Yaml::parse($yaml);
} catch (ParseException $e) {
if ($file) {
$e->setParsedFile($file);
}
throw $e;
}
parent::__construct($content);
}
/**
* Returns Feature keywords (splitted by "|").
*
* @return string
*/
public function getGivenKeywords()
{
return $this->prepareStepString(parent::getGivenKeywords());
}
/**
* Returns When keywords (splitted by "|").
*
* @return string
*/
public function getWhenKeywords()
{
return $this->prepareStepString(parent::getWhenKeywords());
}
/**
* Returns Then keywords (splitted by "|").
*
* @return string
*/
public function getThenKeywords()
{
return $this->prepareStepString(parent::getThenKeywords());
}
/**
* Returns And keywords (splitted by "|").
*
* @return string
*/
public function getAndKeywords()
{
return $this->prepareStepString(parent::getAndKeywords());
}
/**
* Returns But keywords (splitted by "|").
*
* @return string
*/
public function getButKeywords()
{
return $this->prepareStepString(parent::getButKeywords());
}
/**
* Trim *| from the begining of the list.
*
* @param string $keywordsString Keywords string
*
* @return string
*/
private function prepareStepString($keywordsString)
{
if (0 === mb_strpos($keywordsString, '*|', 0, 'UTF-8')) {
$keywordsString = mb_substr($keywordsString, 2, mb_strlen($keywordsString, 'utf8') - 2, 'utf8');
}
return $keywordsString;
}
}

365
vendor/behat/gherkin/src/Behat/Gherkin/Keywords/KeywordsDumper.php vendored

@ -1,365 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Keywords;
/**
* Gherkin keywords dumper.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class KeywordsDumper
{
private $keywords;
private $keywordsDumper;
/**
* Initializes dumper.
*
* @param KeywordsInterface $keywords Keywords instance
*/
public function __construct(KeywordsInterface $keywords)
{
$this->keywords = $keywords;
$this->keywordsDumper = array($this, 'dumpKeywords');
}
/**
* Sets keywords mapper function.
*
* Callable should accept 2 arguments (array $keywords and Boolean $isShort)
*
* @param callable $mapper Mapper function
*/
public function setKeywordsDumperFunction($mapper)
{
$this->keywordsDumper = $mapper;
}
/**
* Defaults keywords dumper.
*
* @param array $keywords Keywords list
* @param Boolean $isShort Is short version
*
* @return string
*/
public function dumpKeywords(array $keywords, $isShort)
{
if ($isShort) {
return 1 < count($keywords) ? '(' . implode('|', $keywords) . ')' : $keywords[0];
}
return $keywords[0];
}
/**
* Dumps keyworded feature into string.
*
* @param string $language Keywords language
* @param Boolean $short Dump short version
* @param bool $excludeAsterisk
*
* @return string|array String for short version and array of features for extended
*/
public function dump($language, $short = true, $excludeAsterisk = false)
{
$this->keywords->setLanguage($language);
$languageComment = '';
if ('en' !== $language) {
$languageComment = "# language: $language\n";
}
$keywords = explode('|', $this->keywords->getFeatureKeywords());
if ($short) {
$keywords = call_user_func($this->keywordsDumper, $keywords, $short);
return trim($languageComment . $this->dumpFeature($keywords, $short, $excludeAsterisk));
}
$features = array();
foreach ($keywords as $keyword) {
$keyword = call_user_func($this->keywordsDumper, array($keyword), $short);
$features[] = trim($languageComment . $this->dumpFeature($keyword, $short, $excludeAsterisk));
}
return $features;
}
/**
* Dumps feature example.
*
* @param string $keyword Item keyword
* @param Boolean $short Dump short version?
*
* @return string
*/
protected function dumpFeature($keyword, $short = true, $excludeAsterisk = false)
{
$dump = <<<GHERKIN
{$keyword}: Internal operations
In order to stay secret
As a secret organization
We need to be able to erase past agents' memory
GHERKIN;
// Background
$keywords = explode('|', $this->keywords->getBackgroundKeywords());
if ($short) {
$keywords = call_user_func($this->keywordsDumper, $keywords, $short);
$dump .= $this->dumpBackground($keywords, $short, $excludeAsterisk);
} else {
$keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short);
$dump .= $this->dumpBackground($keyword, $short, $excludeAsterisk);
}
// Scenario
$keywords = explode('|', $this->keywords->getScenarioKeywords());
if ($short) {
$keywords = call_user_func($this->keywordsDumper, $keywords, $short);
$dump .= $this->dumpScenario($keywords, $short, $excludeAsterisk);
} else {
foreach ($keywords as $keyword) {
$keyword = call_user_func($this->keywordsDumper, array($keyword), $short);
$dump .= $this->dumpScenario($keyword, $short, $excludeAsterisk);
}
}
// Outline
$keywords = explode('|', $this->keywords->getOutlineKeywords());
if ($short) {
$keywords = call_user_func($this->keywordsDumper, $keywords, $short);
$dump .= $this->dumpOutline($keywords, $short, $excludeAsterisk);
} else {
foreach ($keywords as $keyword) {
$keyword = call_user_func($this->keywordsDumper, array($keyword), $short);
$dump .= $this->dumpOutline($keyword, $short, $excludeAsterisk);
}
}
return $dump;
}
/**
* Dumps background example.
*
* @param string $keyword Item keyword
* @param Boolean $short Dump short version?
*
* @return string
*/
protected function dumpBackground($keyword, $short = true, $excludeAsterisk = false)
{
$dump = <<<GHERKIN
{$keyword}:
GHERKIN;
// Given
$dump .= $this->dumpStep(
$this->keywords->getGivenKeywords(),
'there is agent A',
$short,
$excludeAsterisk
);
// And
$dump .= $this->dumpStep(
$this->keywords->getAndKeywords(),
'there is agent B',
$short,
$excludeAsterisk
);
return $dump . "\n";
}
/**
* Dumps scenario example.
*
* @param string $keyword Item keyword
* @param Boolean $short Dump short version?
*
* @return string
*/
protected function dumpScenario($keyword, $short = true, $excludeAsterisk = false)
{
$dump = <<<GHERKIN
{$keyword}: Erasing agent memory
GHERKIN;
// Given
$dump .= $this->dumpStep(
$this->keywords->getGivenKeywords(),
'there is agent J',
$short,
$excludeAsterisk
);
// And
$dump .= $this->dumpStep(
$this->keywords->getAndKeywords(),
'there is agent K',
$short,
$excludeAsterisk
);
// When
$dump .= $this->dumpStep(
$this->keywords->getWhenKeywords(),
'I erase agent K\'s memory',
$short,
$excludeAsterisk
);
// Then
$dump .= $this->dumpStep(
$this->keywords->getThenKeywords(),
'there should be agent J',
$short,
$excludeAsterisk
);
// But
$dump .= $this->dumpStep(
$this->keywords->getButKeywords(),
'there should not be agent K',
$short,
$excludeAsterisk
);
return $dump . "\n";
}
/**
* Dumps outline example.
*
* @param string $keyword Item keyword
* @param Boolean $short Dump short version?
*
* @return string
*/
protected function dumpOutline($keyword, $short = true, $excludeAsterisk = false)
{
$dump = <<<GHERKIN
{$keyword}: Erasing other agents' memory
GHERKIN;
// Given
$dump .= $this->dumpStep(
$this->keywords->getGivenKeywords(),
'there is agent <agent1>',
$short,
$excludeAsterisk
);
// And
$dump .= $this->dumpStep(
$this->keywords->getAndKeywords(),
'there is agent <agent2>',
$short,
$excludeAsterisk
);
// When
$dump .= $this->dumpStep(
$this->keywords->getWhenKeywords(),
'I erase agent <agent2>\'s memory',
$short,
$excludeAsterisk
);
// Then
$dump .= $this->dumpStep(
$this->keywords->getThenKeywords(),
'there should be agent <agent1>',
$short,
$excludeAsterisk
);
// But
$dump .= $this->dumpStep(
$this->keywords->getButKeywords(),
'there should not be agent <agent2>',
$short,
$excludeAsterisk
);
$keywords = explode('|', $this->keywords->getExamplesKeywords());
if ($short) {
$keyword = call_user_func($this->keywordsDumper, $keywords, $short);
} else {
$keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short);
}
$dump .= <<<GHERKIN
{$keyword}:
| agent1 | agent2 |
| D | M |
GHERKIN;
return $dump . "\n";
}
/**
* Dumps step example.
*
* @param string $keywords Item keyword
* @param string $text Step text
* @param Boolean $short Dump short version?
*
* @return string
*/
protected function dumpStep($keywords, $text, $short = true, $excludeAsterisk = false)
{
$dump = '';
$keywords = explode('|', $keywords);
if ($short) {
$keywords = array_map(
function ($keyword) {
return str_replace('<', '', $keyword);
},
$keywords
);
$keywords = call_user_func($this->keywordsDumper, $keywords, $short);
$dump .= <<<GHERKIN
{$keywords} {$text}
GHERKIN;
} else {
foreach ($keywords as $keyword) {
if ($excludeAsterisk && '*' === $keyword) {
continue;
}
$indent = ' ';
if (false !== mb_strpos($keyword, '<', 0, 'utf8')) {
$keyword = mb_substr($keyword, 0, -1, 'utf8');
$indent = '';
}
$keyword = call_user_func($this->keywordsDumper, array($keyword), $short);
$dump .= <<<GHERKIN
{$keyword}{$indent}{$text}
GHERKIN;
}
}
return $dump;
}
}

103
vendor/behat/gherkin/src/Behat/Gherkin/Keywords/KeywordsInterface.php vendored

@ -1,103 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Keywords;
/**
* Keywords holder interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface KeywordsInterface
{
/**
* Sets keywords holder language.
*
* @param string $language Language name
*/
public function setLanguage($language);
/**
* Returns Feature keywords (splitted by "|").
*
* @return string
*/
public function getFeatureKeywords();
/**
* Returns Background keywords (splitted by "|").
*
* @return string
*/
public function getBackgroundKeywords();
/**
* Returns Scenario keywords (splitted by "|").
*
* @return string
*/
public function getScenarioKeywords();
/**
* Returns Scenario Outline keywords (splitted by "|").
*
* @return string
*/
public function getOutlineKeywords();
/**
* Returns Examples keywords (splitted by "|").
*
* @return string
*/
public function getExamplesKeywords();
/**
* Returns Given keywords (splitted by "|").
*
* @return string
*/
public function getGivenKeywords();
/**
* Returns When keywords (splitted by "|").
*
* @return string
*/
public function getWhenKeywords();
/**
* Returns Then keywords (splitted by "|").
*
* @return string
*/
public function getThenKeywords();
/**
* Returns And keywords (splitted by "|").
*
* @return string
*/
public function getAndKeywords();
/**
* Returns But keywords (splitted by "|").
*
* @return string
*/
public function getButKeywords();
/**
* Returns all step keywords (splitted by "|").
*
* @return string
*/
public function getStepKeywords();
}

614
vendor/behat/gherkin/src/Behat/Gherkin/Lexer.php vendored

@ -1,614 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin;
use Behat\Gherkin\Exception\LexerException;
use Behat\Gherkin\Keywords\KeywordsInterface;
/**
* Gherkin lexer.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class Lexer
{
private $language;
private $lines;
private $linesCount;
private $line;
private $trimmedLine;
private $lineNumber;
private $eos;
private $keywords;
private $keywordsCache = array();
private $stepKeywordTypesCache = array();
private $deferredObjects = array();
private $deferredObjectsCount = 0;
private $stashedToken;
private $inPyString = false;
private $pyStringSwallow = 0;
private $featureStarted = false;
private $allowMultilineArguments = false;
private $allowSteps = false;
/**
* Initializes lexer.
*
* @param KeywordsInterface $keywords Keywords holder
*/
public function __construct(KeywordsInterface $keywords)
{
$this->keywords = $keywords;
}
/**
* Sets lexer input.
*
* @param string $input Input string
* @param string $language Language name
*
* @throws Exception\LexerException
*/
public function analyse($input, $language = 'en')
{
// try to detect unsupported encoding
if ('UTF-8' !== mb_detect_encoding($input, 'UTF-8', true)) {
throw new LexerException('Feature file is not in UTF8 encoding');
}
$input = strtr($input, array("\r\n" => "\n", "\r" => "\n"));
$this->lines = explode("\n", $input);
$this->linesCount = count($this->lines);
$this->line = $this->lines[0];
$this->lineNumber = 1;
$this->trimmedLine = null;
$this->eos = false;
$this->deferredObjects = array();
$this->deferredObjectsCount = 0;
$this->stashedToken = null;
$this->inPyString = false;
$this->pyStringSwallow = 0;
$this->featureStarted = false;
$this->allowMultilineArguments = false;
$this->allowSteps = false;
$this->keywords->setLanguage($this->language = $language);
$this->keywordsCache = array();
$this->stepKeywordTypesCache = array();
}
/**
* Returns current lexer language.
*
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* Returns next token or previously stashed one.
*
* @return array
*/
public function getAdvancedToken()
{
return $this->getStashedToken() ?: $this->getNextToken();
}
/**
* Defers token.
*
* @param array $token Token to defer
*/
public function deferToken(array $token)
{
$token['deferred'] = true;
$this->deferredObjects[] = $token;
++$this->deferredObjectsCount;
}
/**
* Predicts for number of tokens.
*
* @return array
*/
public function predictToken()
{
if (null === $this->stashedToken) {
$this->stashedToken = $this->getNextToken();
}
return $this->stashedToken;
}
/**
* Constructs token with specified parameters.
*
* @param string $type Token type
* @param string $value Token value
*
* @return array
*/
public function takeToken($type, $value = null)
{
return array(
'type' => $type,
'line' => $this->lineNumber,
'value' => $value ?: null,
'deferred' => false
);
}
/**
* Consumes line from input & increments line counter.
*/
protected function consumeLine()
{
++$this->lineNumber;
if (($this->lineNumber - 1) === $this->linesCount) {
$this->eos = true;
return;
}
$this->line = $this->lines[$this->lineNumber - 1];
$this->trimmedLine = null;
}
/**
* Returns trimmed version of line.
*
* @return string
*/
protected function getTrimmedLine()
{
return null !== $this->trimmedLine ? $this->trimmedLine : $this->trimmedLine = trim($this->line);
}
/**
* Returns stashed token or null if hasn't.
*
* @return array|null
*/
protected function getStashedToken()
{
$stashedToken = $this->stashedToken;
$this->stashedToken = null;
return $stashedToken;
}
/**
* Returns deferred token or null if hasn't.
*
* @return array|null
*/
protected function getDeferredToken()
{
if (!$this->deferredObjectsCount) {
return null;
}
--$this->deferredObjectsCount;
return array_shift($this->deferredObjects);
}
/**
* Returns next token from input.
*
* @return array
*/
protected function getNextToken()
{
return $this->getDeferredToken()
?: $this->scanEOS()
?: $this->scanLanguage()
?: $this->scanComment()
?: $this->scanPyStringOp()
?: $this->scanPyStringContent()
?: $this->scanStep()
?: $this->scanScenario()
?: $this->scanBackground()
?: $this->scanOutline()
?: $this->scanExamples()
?: $this->scanFeature()
?: $this->scanTags()
?: $this->scanTableRow()
?: $this->scanNewline()
?: $this->scanText();
}
/**
* Scans for token with specified regex.
*
* @param string $regex Regular expression
* @param string $type Expected token type
*
* @return null|array
*/
protected function scanInput($regex, $type)
{
if (!preg_match($regex, $this->line, $matches)) {
return null;
}
$token = $this->takeToken($type, $matches[1]);
$this->consumeLine();
return $token;
}
/**
* Scans for token with specified keywords.
*
* @param string $keywords Keywords (splitted with |)
* @param string $type Expected token type
*
* @return null|array
*/
protected function scanInputForKeywords($keywords, $type)
{
if (!preg_match('/^(\s*)(' . $keywords . '):\s*(.*)/u', $this->line, $matches)) {
return null;
}
$token = $this->takeToken($type, $matches[3]);
$token['keyword'] = $matches[2];
$token['indent'] = mb_strlen($matches[1], 'utf8');
$this->consumeLine();
// turn off language searching
if ('Feature' === $type) {
$this->featureStarted = true;
}
// turn off PyString and Table searching
if ('Feature' === $type || 'Scenario' === $type || 'Outline' === $type) {
$this->allowMultilineArguments = false;
} elseif ('Examples' === $type) {
$this->allowMultilineArguments = true;
}
// turn on steps searching
if ('Scenario' === $type || 'Background' === $type || 'Outline' === $type) {
$this->allowSteps = true;
}
return $token;
}
/**
* Scans EOS from input & returns it if found.
*
* @return null|array
*/
protected function scanEOS()
{
if (!$this->eos) {
return null;
}
return $this->takeToken('EOS');
}
/**
* Returns keywords for provided type.
*
* @param string $type Keyword type
*
* @return string
*/
protected function getKeywords($type)
{
if (!isset($this->keywordsCache[$type])) {
$getter = 'get' . $type . 'Keywords';
$keywords = $this->keywords->$getter();
if ('Step' === $type) {
$padded = array();
foreach (explode('|', $keywords) as $keyword) {
$padded[] = false !== mb_strpos($keyword, '<', 0, 'utf8')
? preg_quote(mb_substr($keyword, 0, -1, 'utf8'), '/') . '\s*'
: preg_quote($keyword, '/') . '\s+';
}
$keywords = implode('|', $padded);
}
$this->keywordsCache[$type] = $keywords;
}
return $this->keywordsCache[$type];
}
/**
* Scans Feature from input & returns it if found.
*
* @return null|array
*/
protected function scanFeature()
{
return $this->scanInputForKeywords($this->getKeywords('Feature'), 'Feature');
}
/**
* Scans Background from input & returns it if found.
*
* @return null|array
*/
protected function scanBackground()
{
return $this->scanInputForKeywords($this->getKeywords('Background'), 'Background');
}
/**
* Scans Scenario from input & returns it if found.
*
* @return null|array
*/
protected function scanScenario()
{
return $this->scanInputForKeywords($this->getKeywords('Scenario'), 'Scenario');
}
/**
* Scans Scenario Outline from input & returns it if found.
*
* @return null|array
*/
protected function scanOutline()
{
return $this->scanInputForKeywords($this->getKeywords('Outline'), 'Outline');
}
/**
* Scans Scenario Outline Examples from input & returns it if found.
*
* @return null|array
*/
protected function scanExamples()
{
return $this->scanInputForKeywords($this->getKeywords('Examples'), 'Examples');
}
/**
* Scans Step from input & returns it if found.
*
* @return null|array
*/
protected function scanStep()
{
if (!$this->allowSteps) {
return null;
}
$keywords = $this->getKeywords('Step');
if (!preg_match('/^\s*(' . $keywords . ')([^\s].+)/u', $this->line, $matches)) {
return null;
}
$keyword = trim($matches[1]);
$token = $this->takeToken('Step', $keyword);
$token['keyword_type'] = $this->getStepKeywordType($keyword);
$token['text'] = $matches[2];
$this->consumeLine();
$this->allowMultilineArguments = true;
return $token;
}
/**
* Scans PyString from input & returns it if found.
*
* @return null|array
*/
protected function scanPyStringOp()
{
if (!$this->allowMultilineArguments) {
return null;
}
if (false === ($pos = mb_strpos($this->line, '"""', 0, 'utf8'))) {
return null;
}
$this->inPyString = !$this->inPyString;
$token = $this->takeToken('PyStringOp');
$this->pyStringSwallow = $pos;
$this->consumeLine();
return $token;
}
/**
* Scans PyString content.
*
* @return null|array
*/
protected function scanPyStringContent()
{
if (!$this->inPyString) {
return null;
}
$token = $this->scanText();
// swallow trailing spaces
$token['value'] = preg_replace('/^\s{0,' . $this->pyStringSwallow . '}/u', '', $token['value']);
return $token;
}
/**
* Scans Table Row from input & returns it if found.
*
* @return null|array
*/
protected function scanTableRow()
{
if (!$this->allowMultilineArguments) {
return null;
}
$line = $this->getTrimmedLine();
if (!isset($line[0]) || '|' !== $line[0] || '|' !== substr($line, -1)) {
return null;
}
$token = $this->takeToken('TableRow');
$line = mb_substr($line, 1, mb_strlen($line, 'utf8') - 2, 'utf8');
$columns = array_map(function ($column) {
return trim(str_replace('\\|', '|', $column));
}, preg_split('/(?<!\\\)\|/u', $line));
$token['columns'] = $columns;
$this->consumeLine();
return $token;
}
/**
* Scans Tags from input & returns it if found.
*
* @return null|array
*/
protected function scanTags()
{
$line = $this->getTrimmedLine();
if (!isset($line[0]) || '@' !== $line[0]) {
return null;
}
$token = $this->takeToken('Tag');
$tags = explode('@', mb_substr($line, 1, mb_strlen($line, 'utf8') - 1, 'utf8'));
$tags = array_map('trim', $tags);
$token['tags'] = $tags;
$this->consumeLine();
return $token;
}
/**
* Scans Language specifier from input & returns it if found.
*
* @return null|array
*/
protected function scanLanguage()
{
if ($this->featureStarted) {
return null;
}
if ($this->inPyString) {
return null;
}
if (0 !== mb_strpos(ltrim($this->line), '#', 0, 'utf8')) {
return null;
}
return $this->scanInput('/^\s*\#\s*language:\s*([\w_\-]+)\s*$/', 'Language');
}
/**
* Scans Comment from input & returns it if found.
*
* @return null|array
*/
protected function scanComment()
{
if ($this->inPyString) {
return null;
}
$line = $this->getTrimmedLine();
if (0 !== mb_strpos($line, '#', 0, 'utf8')) {
return null;
}
$token = $this->takeToken('Comment', $line);
$this->consumeLine();
return $token;
}
/**
* Scans Newline from input & returns it if found.
*
* @return null|array
*/
protected function scanNewline()
{
if ('' !== $this->getTrimmedLine()) {
return null;
}
$token = $this->takeToken('Newline', mb_strlen($this->line, 'utf8'));
$this->consumeLine();
return $token;
}
/**
* Scans text from input & returns it if found.
*
* @return null|array
*/
protected function scanText()
{
$token = $this->takeToken('Text', $this->line);
$this->consumeLine();
return $token;
}
/**
* Returns step type keyword (Given, When, Then, etc.).
*
* @param string $native Step keyword in provided language
* @return string
*/
private function getStepKeywordType($native)
{
// Consider "*" as a AND keyword so that it is normalized to the previous step type
if ('*' === $native) {
return 'And';
}
if (empty($this->stepKeywordTypesCache)) {
$this->stepKeywordTypesCache = array(
'Given' => explode('|', $this->keywords->getGivenKeywords()),
'When' => explode('|', $this->keywords->getWhenKeywords()),
'Then' => explode('|', $this->keywords->getThenKeywords()),
'And' => explode('|', $this->keywords->getAndKeywords()),
'But' => explode('|', $this->keywords->getButKeywords())
);
}
foreach ($this->stepKeywordTypesCache as $type => $keywords) {
if (in_array($native, $keywords) || in_array($native . '<', $keywords)) {
return $type;
}
}
return 'Given';
}
}

72
vendor/behat/gherkin/src/Behat/Gherkin/Loader/AbstractFileLoader.php vendored

@ -1,72 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
/**
* Abstract filesystem loader.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
abstract class AbstractFileLoader implements FileLoaderInterface
{
protected $basePath;
/**
* Sets base features path.
*
* @param string $path Base loader path
*/
public function setBasePath($path)
{
$this->basePath = realpath($path);
}
/**
* Finds relative path for provided absolute (relative to base features path).
*
* @param string $path Absolute path
*
* @return string
*/
protected function findRelativePath($path)
{
if (null !== $this->basePath) {
return strtr($path, array($this->basePath . DIRECTORY_SEPARATOR => ''));
}
return $path;
}
/**
* Finds absolute path for provided relative (relative to base features path).
*
* @param string $path Relative path
*
* @return string
*/
protected function findAbsolutePath($path)
{
if (is_file($path) || is_dir($path)) {
return realpath($path);
}
if (null === $this->basePath) {
return false;
}
if (is_file($this->basePath . DIRECTORY_SEPARATOR . $path)
|| is_dir($this->basePath . DIRECTORY_SEPARATOR . $path)) {
return realpath($this->basePath . DIRECTORY_SEPARATOR . $path);
}
return false;
}
}

269
vendor/behat/gherkin/src/Behat/Gherkin/Loader/ArrayLoader.php vendored

@ -1,269 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
use Behat\Gherkin\Node\BackgroundNode;
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\OutlineNode;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\ScenarioNode;
use Behat\Gherkin\Node\StepNode;
use Behat\Gherkin\Node\TableNode;
/**
* From-array loader.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class ArrayLoader implements LoaderInterface
{
/**
* Checks if current loader supports provided resource.
*
* @param mixed $resource Resource to load
*
* @return Boolean
*/
public function supports($resource)
{
return is_array($resource) && (isset($resource['features']) || isset($resource['feature']));
}
/**
* Loads features from provided resource.
*
* @param mixed $resource Resource to load
*
* @return FeatureNode[]
*/
public function load($resource)
{
$features = array();
if (isset($resource['features'])) {
foreach ($resource['features'] as $iterator => $hash) {
$feature = $this->loadFeatureHash($hash, $iterator);
$features[] = $feature;
}
} elseif (isset($resource['feature'])) {
$feature = $this->loadFeatureHash($resource['feature']);
$features[] = $feature;
}
return $features;
}
/**
* Loads feature from provided feature hash.
*
* @param array $hash Feature hash
* @param integer $line
*
* @return FeatureNode
*/
protected function loadFeatureHash(array $hash, $line = 0)
{
$hash = array_merge(
array(
'title' => null,
'description' => null,
'tags' => array(),
'keyword' => 'Feature',
'language' => 'en',
'line' => $line,
'scenarios' => array(),
),
$hash
);
$background = isset($hash['background']) ? $this->loadBackgroundHash($hash['background']) : null;
$scenarios = array();
foreach ((array) $hash['scenarios'] as $scenarioIterator => $scenarioHash) {
if (isset($scenarioHash['type']) && 'outline' === $scenarioHash['type']) {
$scenarios[] = $this->loadOutlineHash($scenarioHash, $scenarioIterator);
} else {
$scenarios[] = $this->loadScenarioHash($scenarioHash, $scenarioIterator);
}
}
return new FeatureNode($hash['title'], $hash['description'], $hash['tags'], $background, $scenarios, $hash['keyword'], $hash['language'], null, $hash['line']);
}
/**
* Loads background from provided hash.
*
* @param array $hash Background hash
*
* @return BackgroundNode
*/
protected function loadBackgroundHash(array $hash)
{
$hash = array_merge(
array(
'title' => null,
'keyword' => 'Background',
'line' => 0,
'steps' => array(),
),
$hash
);
$steps = $this->loadStepsHash($hash['steps']);
return new BackgroundNode($hash['title'], $steps, $hash['keyword'], $hash['line']);
}
/**
* Loads scenario from provided scenario hash.
*
* @param array $hash Scenario hash
* @param integer $line Scenario definition line
*
* @return ScenarioNode
*/
protected function loadScenarioHash(array $hash, $line = 0)
{
$hash = array_merge(
array(
'title' => null,
'tags' => array(),
'keyword' => 'Scenario',
'line' => $line,
'steps' => array(),
),
$hash
);
$steps = $this->loadStepsHash($hash['steps']);
return new ScenarioNode($hash['title'], $hash['tags'], $steps, $hash['keyword'], $hash['line']);
}
/**
* Loads outline from provided outline hash.
*
* @param array $hash Outline hash
* @param integer $line Outline definition line
*
* @return OutlineNode
*/
protected function loadOutlineHash(array $hash, $line = 0)
{
$hash = array_merge(
array(
'title' => null,
'tags' => array(),
'keyword' => 'Scenario Outline',
'line' => $line,
'steps' => array(),
'examples' => array(),
),
$hash
);
$steps = $this->loadStepsHash($hash['steps']);
if (isset($hash['examples']['keyword'])) {
$examplesKeyword = $hash['examples']['keyword'];
unset($hash['examples']['keyword']);
} else {
$examplesKeyword = 'Examples';
}
$examples = new ExampleTableNode($hash['examples'], $examplesKeyword);
return new OutlineNode($hash['title'], $hash['tags'], $steps, $examples, $hash['keyword'], $hash['line']);
}
/**
* Loads steps from provided hash.
*
* @param array $hash
*
* @return StepNode[]
*/
private function loadStepsHash(array $hash)
{
$steps = array();
foreach ($hash as $stepIterator => $stepHash) {
$steps[] = $this->loadStepHash($stepHash, $stepIterator);
}
return $steps;
}
/**
* Loads step from provided hash.
*
* @param array $hash Step hash
* @param integer $line Step definition line
*
* @return StepNode
*/
protected function loadStepHash(array $hash, $line = 0)
{
$hash = array_merge(
array(
'keyword_type' => 'Given',
'type' => 'Given',
'text' => null,
'keyword' => 'Scenario',
'line' => $line,
'arguments' => array(),
),
$hash
);
$arguments = array();
foreach ($hash['arguments'] as $argumentHash) {
if ('table' === $argumentHash['type']) {
$arguments[] = $this->loadTableHash($argumentHash['rows']);
} elseif ('pystring' === $argumentHash['type']) {
$arguments[] = $this->loadPyStringHash($argumentHash, $hash['line'] + 1);
}
}
return new StepNode($hash['type'], $hash['text'], $arguments, $hash['line'], $hash['keyword_type']);
}
/**
* Loads table from provided hash.
*
* @param array $hash Table hash
*
* @return TableNode
*/
protected function loadTableHash(array $hash)
{
return new TableNode($hash);
}
/**
* Loads PyString from provided hash.
*
* @param array $hash PyString hash
* @param integer $line
*
* @return PyStringNode
*/
protected function loadPyStringHash(array $hash, $line = 0)
{
$line = isset($hash['line']) ? $hash['line'] : $line;
$strings = array();
foreach (explode("\n", $hash['text']) as $string) {
$strings[] = $string;
}
return new PyStringNode($strings, $line);
}
}

80
vendor/behat/gherkin/src/Behat/Gherkin/Loader/DirectoryLoader.php vendored

@ -1,80 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
use Behat\Gherkin\Gherkin;
use Behat\Gherkin\Node\FeatureNode;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
/**
* Directory contents loader.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class DirectoryLoader extends AbstractFileLoader
{
protected $gherkin;
/**
* Initializes loader.
*
* @param Gherkin $gherkin Gherkin manager
*/
public function __construct(Gherkin $gherkin)
{
$this->gherkin = $gherkin;
}
/**
* Checks if current loader supports provided resource.
*
* @param mixed $path Resource to load
*
* @return Boolean
*/
public function supports($path)
{
return is_string($path)
&& is_dir($this->findAbsolutePath($path));
}
/**
* Loads features from provided resource.
*
* @param string $path Resource to load
*
* @return FeatureNode[]
*/
public function load($path)
{
$path = $this->findAbsolutePath($path);
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS)
);
$paths = array_map('strval', iterator_to_array($iterator));
uasort($paths, 'strnatcasecmp');
$features = array();
foreach ($paths as $path) {
$path = (string) $path;
$loader = $this->gherkin->resolveLoader($path);
if (null !== $loader) {
$features = array_merge($features, $loader->load($path));
}
}
return $features;
}
}

26
vendor/behat/gherkin/src/Behat/Gherkin/Loader/FileLoaderInterface.php vendored

@ -1,26 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
/**
* File Loader interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface FileLoaderInterface extends LoaderInterface
{
/**
* Sets base features path.
*
* @param string $path Base loader path
*/
public function setBasePath($path);
}

102
vendor/behat/gherkin/src/Behat/Gherkin/Loader/GherkinFileLoader.php vendored

@ -1,102 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
use Behat\Gherkin\Cache\CacheInterface;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Parser;
/**
* Gherkin *.feature files loader.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class GherkinFileLoader extends AbstractFileLoader
{
protected $parser;
protected $cache;
/**
* Initializes loader.
*
* @param Parser $parser Parser
* @param CacheInterface $cache Cache layer
*/
public function __construct(Parser $parser, CacheInterface $cache = null)
{
$this->parser = $parser;
$this->cache = $cache;
}
/**
* Sets cache layer.
*
* @param CacheInterface $cache Cache layer
*/
public function setCache(CacheInterface $cache)
{
$this->cache = $cache;
}
/**
* Checks if current loader supports provided resource.
*
* @param mixed $path Resource to load
*
* @return Boolean
*/
public function supports($path)
{
return is_string($path)
&& is_file($absolute = $this->findAbsolutePath($path))
&& 'feature' === pathinfo($absolute, PATHINFO_EXTENSION);
}
/**
* Loads features from provided resource.
*
* @param string $path Resource to load
*
* @return FeatureNode[]
*/
public function load($path)
{
$path = $this->findAbsolutePath($path);
if ($this->cache) {
if ($this->cache->isFresh($path, filemtime($path))) {
$feature = $this->cache->read($path);
} elseif (null !== $feature = $this->parseFeature($path)) {
$this->cache->write($path, $feature);
}
} else {
$feature = $this->parseFeature($path);
}
return null !== $feature ? array($feature) : array();
}
/**
* Parses feature at provided absolute path.
*
* @param string $path Feature path
*
* @return FeatureNode
*/
protected function parseFeature($path)
{
$filename = $this->findRelativePath($path);
$content = file_get_contents($path);
$feature = $this->parser->parse($content, $filename);
return $feature;
}
}

39
vendor/behat/gherkin/src/Behat/Gherkin/Loader/LoaderInterface.php vendored

@ -1,39 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
use Behat\Gherkin\Node\FeatureNode;
/**
* Loader interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface LoaderInterface
{
/**
* Checks if current loader supports provided resource.
*
* @param mixed $resource Resource to load
*
* @return Boolean
*/
public function supports($resource);
/**
* Loads features from provided resource.
*
* @param mixed $resource Resource to load
*
* @return FeatureNode[]
*/
public function load($resource);
}

73
vendor/behat/gherkin/src/Behat/Gherkin/Loader/YamlFileLoader.php vendored

@ -1,73 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Loader;
use Behat\Gherkin\Node\FeatureNode;
use Symfony\Component\Yaml\Yaml;
/**
* Yaml files loader.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class YamlFileLoader extends AbstractFileLoader
{
private $loader;
public function __construct()
{
$this->loader = new ArrayLoader();
}
/**
* Checks if current loader supports provided resource.
*
* @param mixed $path Resource to load
*
* @return Boolean
*/
public function supports($path)
{
return is_string($path)
&& is_file($absolute = $this->findAbsolutePath($path))
&& 'yml' === pathinfo($absolute, PATHINFO_EXTENSION);
}
/**
* Loads features from provided resource.
*
* @param string $path Resource to load
*
* @return FeatureNode[]
*/
public function load($path)
{
$path = $this->findAbsolutePath($path);
$hash = Yaml::parse(file_get_contents($path));
$features = $this->loader->load($hash);
$filename = $this->findRelativePath($path);
return array_map(function (FeatureNode $feature) use ($filename) {
return new FeatureNode(
$feature->getTitle(),
$feature->getDescription(),
$feature->getTags(),
$feature->getBackground(),
$feature->getScenarios(),
$feature->getKeyword(),
$feature->getLanguage(),
$filename,
$feature->getLine()
);
}, $features);
}
}

20
vendor/behat/gherkin/src/Behat/Gherkin/Node/ArgumentInterface.php vendored

@ -1,20 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin arguments interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface ArgumentInterface extends NodeInterface
{
}

112
vendor/behat/gherkin/src/Behat/Gherkin/Node/BackgroundNode.php vendored

@ -1,112 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin Background.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class BackgroundNode implements ScenarioLikeInterface
{
/**
* @var string
*/
private $title;
/**
* @var StepNode[]
*/
private $steps = array();
/**
* @var string
*/
private $keyword;
/**
* @var integer
*/
private $line;
/**
* Initializes background.
*
* @param null|string $title
* @param StepNode[] $steps
* @param string $keyword
* @param integer $line
*/
public function __construct($title, array $steps, $keyword, $line)
{
$this->title = $title;
$this->steps = $steps;
$this->keyword = $keyword;
$this->line = $line;
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'Background';
}
/**
* Returns background title.
*
* @return null|string
*/
public function getTitle()
{
return $this->title;
}
/**
* Checks if background has steps.
*
* @return Boolean
*/
public function hasSteps()
{
return 0 < count($this->steps);
}
/**
* Returns background steps.
*
* @return StepNode[]
*/
public function getSteps()
{
return $this->steps;
}
/**
* Returns background keyword.
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Returns background declaration line number.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
}

274
vendor/behat/gherkin/src/Behat/Gherkin/Node/ExampleNode.php vendored

@ -1,274 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin Outline Example.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class ExampleNode implements ScenarioInterface
{
/**
* @var string
*/
private $title;
/**
* @var string[]
*/
private $tags;
/**
* @var StepNode[]
*/
private $outlineSteps;
/**
* @var string[]
*/
private $tokens;
/**
* @var integer
*/
private $line;
/**
* @var null|StepNode[]
*/
private $steps;
/**
* @var string
*/
private $outlineTitle;
/**
* Initializes outline.
*
* @param string $title
* @param string[] $tags
* @param StepNode[] $outlineSteps
* @param string[] $tokens
* @param integer $line
* @param string|null $outlineTitle
*/
public function __construct($title, array $tags, $outlineSteps, array $tokens, $line, $outlineTitle = null)
{
$this->title = $title;
$this->tags = $tags;
$this->outlineSteps = $outlineSteps;
$this->tokens = $tokens;
$this->line = $line;
$this->outlineTitle = $outlineTitle;
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'Example';
}
/**
* Returns node keyword.
*
* @return string
*/
public function getKeyword()
{
return $this->getNodeType();
}
/**
* Returns example title.
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Checks if outline is tagged with tag.
*
* @param string $tag
*
* @return Boolean
*/
public function hasTag($tag)
{
return in_array($tag, $this->getTags());
}
/**
* Checks if outline has tags (both inherited from feature and own).
*
* @return Boolean
*/
public function hasTags()
{
return 0 < count($this->getTags());
}
/**
* Returns outline tags (including inherited from feature).
*
* @return string[]
*/
public function getTags()
{
return $this->tags;
}
/**
* Checks if outline has steps.
*
* @return Boolean
*/
public function hasSteps()
{
return 0 < count($this->outlineSteps);
}
/**
* Returns outline steps.
*
* @return StepNode[]
*/
public function getSteps()
{
return $this->steps = $this->steps ? : $this->createExampleSteps();
}
/**
* Returns example tokens.
*
* @return string[]
*/
public function getTokens()
{
return $this->tokens;
}
/**
* Returns outline declaration line number.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
/**
* Returns outline title.
*
* @return string
*/
public function getOutlineTitle()
{
return $this->outlineTitle;
}
/**
* Creates steps for this example from abstract outline steps.
*
* @return StepNode[]
*/
protected function createExampleSteps()
{
$steps = array();
foreach ($this->outlineSteps as $outlineStep) {
$keyword = $outlineStep->getKeyword();
$keywordType = $outlineStep->getKeywordType();
$text = $this->replaceTextTokens($outlineStep->getText());
$args = $this->replaceArgumentsTokens($outlineStep->getArguments());
$line = $outlineStep->getLine();
$steps[] = new StepNode($keyword, $text, $args, $line, $keywordType);
}
return $steps;
}
/**
* Replaces tokens in arguments with row values.
*
* @param ArgumentInterface[] $arguments
*
* @return ArgumentInterface[]
*/
protected function replaceArgumentsTokens(array $arguments)
{
foreach ($arguments as $num => $argument) {
if ($argument instanceof TableNode) {
$arguments[$num] = $this->replaceTableArgumentTokens($argument);
}
if ($argument instanceof PyStringNode) {
$arguments[$num] = $this->replacePyStringArgumentTokens($argument);
}
}
return $arguments;
}
/**
* Replaces tokens in table with row values.
*
* @param TableNode $argument
*
* @return TableNode
*/
protected function replaceTableArgumentTokens(TableNode $argument)
{
$table = $argument->getTable();
foreach ($table as $line => $row) {
foreach (array_keys($row) as $col) {
$table[$line][$col] = $this->replaceTextTokens($table[$line][$col]);
}
}
return new TableNode($table);
}
/**
* Replaces tokens in PyString with row values.
*
* @param PyStringNode $argument
*
* @return PyStringNode
*/
protected function replacePyStringArgumentTokens(PyStringNode $argument)
{
$strings = $argument->getStrings();
foreach ($strings as $line => $string) {
$strings[$line] = $this->replaceTextTokens($strings[$line]);
}
return new PyStringNode($strings, $argument->getLine());
}
/**
* Replaces tokens in text with row values.
*
* @param string $text
*
* @return string
*/
protected function replaceTextTokens($text)
{
foreach ($this->tokens as $key => $val) {
$text = str_replace('<' . $key . '>', $val, $text);
}
return $text;
}
}

57
vendor/behat/gherkin/src/Behat/Gherkin/Node/ExampleTableNode.php vendored

@ -1,57 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin Outline Example Table.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class ExampleTableNode extends TableNode
{
/**
* @var string
*/
private $keyword;
/**
* Initializes example table.
*
* @param array $table Table in form of [$rowLineNumber => [$val1, $val2, $val3]]
* @param string $keyword
*/
public function __construct(array $table, $keyword)
{
$this->keyword = $keyword;
parent::__construct($table);
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'ExampleTable';
}
/**
* Returns example table keyword.
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
}

243
vendor/behat/gherkin/src/Behat/Gherkin/Node/FeatureNode.php vendored

@ -1,243 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin Feature.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class FeatureNode implements KeywordNodeInterface, TaggedNodeInterface
{
/**
* @var null|string
*/
private $title;
/**
* @var null|string
*/
private $description;
/**
* @var string[]
*/
private $tags = array();
/**
* @var null|BackgroundNode
*/
private $background;
/**
* @var ScenarioInterface[]
*/
private $scenarios = array();
/**
* @var string
*/
private $keyword;
/**
* @var string
*/
private $language;
/**
* @var null|string
*/
private $file;
/**
* @var integer
*/
private $line;
/**
* Initializes feature.
*
* @param null|string $title
* @param null|string $description
* @param string[] $tags
* @param null|BackgroundNode $background
* @param ScenarioInterface[] $scenarios
* @param string $keyword
* @param string $language
* @param null|string $file
* @param integer $line
*/
public function __construct(
$title,
$description,
array $tags,
BackgroundNode $background = null,
array $scenarios,
$keyword,
$language,
$file,
$line
) {
$this->title = $title;
$this->description = $description;
$this->tags = $tags;
$this->background = $background;
$this->scenarios = $scenarios;
$this->keyword = $keyword;
$this->language = $language;
$this->file = $file;
$this->line = $line;
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'Feature';
}
/**
* Returns feature title.
*
* @return null|string
*/
public function getTitle()
{
return $this->title;
}
/**
* Checks if feature has a description.
*
* @return Boolean
*/
public function hasDescription()
{
return !empty($this->description);
}
/**
* Returns feature description.
*
* @return null|string
*/
public function getDescription()
{
return $this->description;
}
/**
* Checks if feature is tagged with tag.
*
* @param string $tag
*
* @return Boolean
*/
public function hasTag($tag)
{
return in_array($tag, $this->tags);
}
/**
* Checks if feature has tags.
*
* @return Boolean
*/
public function hasTags()
{
return 0 < count($this->tags);
}
/**
* Returns feature tags.
*
* @return string[]
*/
public function getTags()
{
return $this->tags;
}
/**
* Checks if feature has background.
*
* @return Boolean
*/
public function hasBackground()
{
return null !== $this->background;
}
/**
* Returns feature background.
*
* @return null|BackgroundNode
*/
public function getBackground()
{
return $this->background;
}
/**
* Checks if feature has scenarios.
*
* @return Boolean
*/
public function hasScenarios()
{
return 0 < count($this->scenarios);
}
/**
* Returns feature scenarios.
*
* @return ScenarioInterface[]
*/
public function getScenarios()
{
return $this->scenarios;
}
/**
* Returns feature keyword.
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Returns feature language.
*
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* Returns feature file.
*
* @return null|string
*/
public function getFile()
{
return $this->file;
}
/**
* Returns feature declaration line number.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
}

33
vendor/behat/gherkin/src/Behat/Gherkin/Node/KeywordNodeInterface.php vendored

@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin keyword node interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface KeywordNodeInterface extends NodeInterface
{
/**
* Returns node keyword.
*
* @return string
*/
public function getKeyword();
/**
* Returns node title.
*
* @return null|string
*/
public function getTitle();
}

33
vendor/behat/gherkin/src/Behat/Gherkin/Node/NodeInterface.php vendored

@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin node interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface NodeInterface
{
/**
* Returns node type string
*
* @return string
*/
public function getNodeType();
/**
* Returns feature declaration line number.
*
* @return integer
*/
public function getLine();
}

218
vendor/behat/gherkin/src/Behat/Gherkin/Node/OutlineNode.php vendored

@ -1,218 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin Outline.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class OutlineNode implements ScenarioInterface
{
/**
* @var string
*/
private $title;
/**
* @var string[]
*/
private $tags;
/**
* @var StepNode[]
*/
private $steps;
/**
* @var ExampleTableNode
*/
private $table;
/**
* @var string
*/
private $keyword;
/**
* @var integer
*/
private $line;
/**
* @var null|ExampleNode[]
*/
private $examples;
/**
* Initializes outline.
*
* @param null|string $title
* @param string[] $tags
* @param StepNode[] $steps
* @param ExampleTableNode $table
* @param string $keyword
* @param integer $line
*/
public function __construct(
$title,
array $tags,
array $steps,
ExampleTableNode $table,
$keyword,
$line
) {
$this->title = $title;
$this->tags = $tags;
$this->steps = $steps;
$this->table = $table;
$this->keyword = $keyword;
$this->line = $line;
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'Outline';
}
/**
* Returns outline title.
*
* @return null|string
*/
public function getTitle()
{
return $this->title;
}
/**
* Checks if outline is tagged with tag.
*
* @param string $tag
*
* @return Boolean
*/
public function hasTag($tag)
{
return in_array($tag, $this->getTags());
}
/**
* Checks if outline has tags (both inherited from feature and own).
*
* @return Boolean
*/
public function hasTags()
{
return 0 < count($this->getTags());
}
/**
* Returns outline tags (including inherited from feature).
*
* @return string[]
*/
public function getTags()
{
return $this->tags;
}
/**
* Checks if outline has steps.
*
* @return Boolean
*/
public function hasSteps()
{
return 0 < count($this->steps);
}
/**
* Returns outline steps.
*
* @return StepNode[]
*/
public function getSteps()
{
return $this->steps;
}
/**
* Checks if outline has examples.
*
* @return Boolean
*/
public function hasExamples()
{
return 0 < count($this->table->getColumnsHash());
}
/**
* Returns examples table.
*
* @return ExampleTableNode
*/
public function getExampleTable()
{
return $this->table;
}
/**
* Returns list of examples for the outline.
*
* @return ExampleNode[]
*/
public function getExamples()
{
return $this->examples = $this->examples ? : $this->createExamples();
}
/**
* Returns outline keyword.
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Returns outline declaration line number.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
/**
* Creates examples for this outline using examples table.
*
* @return ExampleNode[]
*/
protected function createExamples()
{
$examples = array();
foreach ($this->table->getColumnsHash() as $rowNum => $row) {
$examples[] = new ExampleNode(
$this->table->getRowAsString($rowNum + 1),
$this->tags,
$this->getSteps(),
$row,
$this->table->getRowLine($rowNum + 1),
$this->getTitle()
);
}
return $examples;
}
}

90
vendor/behat/gherkin/src/Behat/Gherkin/Node/PyStringNode.php vendored

@ -1,90 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin PyString argument.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class PyStringNode implements ArgumentInterface
{
/**
* @var array
*/
private $strings = array();
/**
* @var integer
*/
private $line;
/**
* Initializes PyString.
*
* @param array $strings String in form of [$stringLine]
* @param integer $line Line number where string been started
*/
public function __construct(array $strings, $line)
{
$this->strings = $strings;
$this->line = $line;
}
/**
* Returns node type.
*
* @return string
*/
public function getNodeType()
{
return 'PyString';
}
/**
* Returns entire PyString lines set.
*
* @return array
*/
public function getStrings()
{
return $this->strings;
}
/**
* Returns raw string.
*
* @return string
*/
public function getRaw()
{
return implode("\n", $this->strings);
}
/**
* Converts PyString into string.
*
* @return string
*/
public function __toString()
{
return $this->getRaw();
}
/**
* Returns line number at which PyString was started.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
}

20
vendor/behat/gherkin/src/Behat/Gherkin/Node/ScenarioInterface.php vendored

@ -1,20 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin scenario interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface ScenarioInterface extends ScenarioLikeInterface, TaggedNodeInterface
{
}

20
vendor/behat/gherkin/src/Behat/Gherkin/Node/ScenarioLikeInterface.php vendored

@ -1,20 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin scenario-like interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface ScenarioLikeInterface extends KeywordNodeInterface, StepContainerInterface
{
}

150
vendor/behat/gherkin/src/Behat/Gherkin/Node/ScenarioNode.php vendored

@ -1,150 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Represents Gherkin Scenario.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class ScenarioNode implements ScenarioInterface
{
/**
* @var string
*/
private $title;
/**
* @var array
*/
private $tags = array();
/**
* @var StepNode[]
*/
private $steps = array();
/**
* @var string
*/
private $keyword;
/**
* @var integer
*/
private $line;
/**
* Initializes scenario.
*
* @param null|string $title
* @param array $tags
* @param StepNode[] $steps
* @param string $keyword
* @param integer $line
*/
public function __construct($title, array $tags, array $steps, $keyword, $line)
{
$this->title = $title;
$this->tags = $tags;
$this->steps = $steps;
$this->keyword = $keyword;
$this->line = $line;
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'Scenario';
}
/**
* Returns scenario title.
*
* @return null|string
*/
public function getTitle()
{
return $this->title;
}
/**
* Checks if scenario is tagged with tag.
*
* @param string $tag
*
* @return Boolean
*/
public function hasTag($tag)
{
return in_array($tag, $this->getTags());
}
/**
* Checks if scenario has tags (both inherited from feature and own).
*
* @return Boolean
*/
public function hasTags()
{
return 0 < count($this->getTags());
}
/**
* Returns scenario tags (including inherited from feature).
*
* @return array
*/
public function getTags()
{
return $this->tags;
}
/**
* Checks if scenario has steps.
*
* @return Boolean
*/
public function hasSteps()
{
return 0 < count($this->steps);
}
/**
* Returns scenario steps.
*
* @return StepNode[]
*/
public function getSteps()
{
return $this->steps;
}
/**
* Returns scenario keyword.
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Returns scenario declaration line number.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
}

33
vendor/behat/gherkin/src/Behat/Gherkin/Node/StepContainerInterface.php vendored

@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin step container interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface StepContainerInterface extends NodeInterface
{
/**
* Checks if container has steps.
*
* @return Boolean
*/
public function hasSteps();
/**
* Returns container steps.
*
* @return StepNode[]
*/
public function getSteps();
}

152
vendor/behat/gherkin/src/Behat/Gherkin/Node/StepNode.php vendored

@ -1,152 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
use Behat\Gherkin\Exception\NodeException;
/**
* Represents Gherkin Step.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class StepNode implements NodeInterface
{
/**
* @var string
*/
private $keyword;
/**
* @var string
*/
private $keywordType;
/**
* @var string
*/
private $text;
/**
* @var ArgumentInterface[]
*/
private $arguments = array();
/**
* @var integer
*/
private $line;
/**
* Initializes step.
*
* @param string $keyword
* @param string $text
* @param ArgumentInterface[] $arguments
* @param integer $line
* @param string $keywordType
*/
public function __construct($keyword, $text, array $arguments, $line, $keywordType = null)
{
if (count($arguments) > 1) {
throw new NodeException(sprintf(
'Steps could have only one argument, but `%s %s` have %d.',
$keyword,
$text,
count($arguments)
));
}
$this->keyword = $keyword;
$this->text = $text;
$this->arguments = $arguments;
$this->line = $line;
$this->keywordType = $keywordType ?: 'Given';
}
/**
* Returns node type string
*
* @return string
*/
public function getNodeType()
{
return 'Step';
}
/**
* Returns step keyword in provided language (Given, When, Then, etc.).
*
* @return string
*
* @deprecated use getKeyword() instead
*/
public function getType()
{
return $this->getKeyword();
}
/**
* Returns step keyword in provided language (Given, When, Then, etc.).
*
* @return string
*
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* Returns step type keyword (Given, When, Then, etc.).
*
* @return string
*/
public function getKeywordType()
{
return $this->keywordType;
}
/**
* Returns step text.
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Checks if step has arguments.
*
* @return Boolean
*/
public function hasArguments()
{
return 0 < count($this->arguments);
}
/**
* Returns step arguments.
*
* @return ArgumentInterface[]
*/
public function getArguments()
{
return $this->arguments;
}
/**
* Returns step declaration line number.
*
* @return integer
*/
public function getLine()
{
return $this->line;
}
}

347
vendor/behat/gherkin/src/Behat/Gherkin/Node/TableNode.php vendored

@ -1,347 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
use ArrayIterator;
use Behat\Gherkin\Exception\NodeException;
use Iterator;
use IteratorAggregate;
/**
* Represents Gherkin Table argument.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class TableNode implements ArgumentInterface, IteratorAggregate
{
/**
* @var array
*/
private $table;
/**
* @var integer
*/
private $maxLineLength = array();
/**
* Initializes table.
*
* @param array $table Table in form of [$rowLineNumber => [$val1, $val2, $val3]]
*
* @throws NodeException If the given table is invalid
*/
public function __construct(array $table)
{
$this->table = $table;
$columnCount = null;
foreach ($this->getRows() as $row) {
if (!is_array($row)) {
throw new NodeException('Table is not two-dimensional.');
}
if ($columnCount === null) {
$columnCount = count($row);
}
if (count($row) !== $columnCount) {
throw new NodeException('Table does not have same number of columns in every row.');
}
if (!is_array($row)) {
throw new NodeException('Table is not two-dimensional.');
}
foreach ($row as $column => $string) {
if (!isset($this->maxLineLength[$column])) {
$this->maxLineLength[$column] = 0;
}
if (!is_scalar($string)) {
throw new NodeException('Table is not two-dimensional.');
}
$this->maxLineLength[$column] = max($this->maxLineLength[$column], mb_strlen($string, 'utf8'));
}
}
}
/**
* Creates a table from a given list.
*
* @param array $list One-dimensional array
*
* @return TableNode
*
* @throws NodeException If the given list is not a one-dimensional array
*/
public static function fromList(array $list)
{
if (count($list) !== count($list, COUNT_RECURSIVE)) {
throw new NodeException('List is not a one-dimensional array.');
}
array_walk($list, function (&$item) {
$item = array($item);
});
return new self($list);
}
/**
* Returns node type.
*
* @return string
*/
public function getNodeType()
{
return 'Table';
}
/**
* Returns table hash, formed by columns (ColumnsHash).
*
* @return array
*/
public function getHash()
{
return $this->getColumnsHash();
}
/**
* Returns table hash, formed by columns.
*
* @return array
*/
public function getColumnsHash()
{
$rows = $this->getRows();
$keys = array_shift($rows);
$hash = array();
foreach ($rows as $row) {
$hash[] = array_combine($keys, $row);
}
return $hash;
}
/**
* Returns table hash, formed by rows.
*
* @return array
*/
public function getRowsHash()
{
$hash = array();
foreach ($this->getRows() as $row) {
$hash[array_shift($row)] = (1 == count($row)) ? $row[0] : $row;
}
return $hash;
}
/**
* Returns numerated table lines.
* Line numbers are keys, lines are values.
*
* @return array
*/
public function getTable()
{
return $this->table;
}
/**
* Returns table rows.
*
* @return array
*/
public function getRows()
{
return array_values($this->table);
}
/**
* Returns table definition lines.
*
* @return array
*/
public function getLines()
{
return array_keys($this->table);
}
/**
* Returns specific row in a table.
*
* @param integer $index Row number
*
* @return array
*
* @throws NodeException If row with specified index does not exist
*/
public function getRow($index)
{
$rows = $this->getRows();
if (!isset($rows[$index])) {
throw new NodeException(sprintf('Rows #%d does not exist in table.', $index));
}
return $rows[$index];
}
/**
* Returns specific column in a table.
*
* @param integer $index Column number
*
* @return array
*
* @throws NodeException If column with specified index does not exist
*/
public function getColumn($index)
{
if ($index >= count($this->getRow(0))) {
throw new NodeException(sprintf('Column #%d does not exist in table.', $index));
}
$rows = $this->getRows();
$column = array();
foreach ($rows as $row) {
$column[] = $row[$index];
}
return $column;
}
/**
* Returns line number at which specific row was defined.
*
* @param integer $index
*
* @return integer
*
* @throws NodeException If row with specified index does not exist
*/
public function getRowLine($index)
{
$lines = array_keys($this->table);
if (!isset($lines[$index])) {
throw new NodeException(sprintf('Rows #%d does not exist in table.', $index));
}
return $lines[$index];
}
/**
* Converts row into delimited string.
*
* @param integer $rowNum Row number
*
* @return string
*/
public function getRowAsString($rowNum)
{
$values = array();
foreach ($this->getRow($rowNum) as $column => $value) {
$values[] = $this->padRight(' ' . $value . ' ', $this->maxLineLength[$column] + 2);
}
return sprintf('|%s|', implode('|', $values));
}
/**
* Converts row into delimited string.
*
* @param integer $rowNum Row number
* @param callable $wrapper Wrapper function
*
* @return string
*/
public function getRowAsStringWithWrappedValues($rowNum, $wrapper)
{
$values = array();
foreach ($this->getRow($rowNum) as $column => $value) {
$value = $this->padRight(' ' . $value . ' ', $this->maxLineLength[$column] + 2);
$values[] = call_user_func($wrapper, $value, $column);
}
return sprintf('|%s|', implode('|', $values));
}
/**
* Converts entire table into string
*
* @return string
*/
public function getTableAsString()
{
$lines = array();
for ($i = 0; $i < count($this->getRows()); $i++) {
$lines[] = $this->getRowAsString($i);
}
return implode("\n", $lines);
}
/**
* Returns line number at which table was started.
*
* @return integer
*/
public function getLine()
{
return $this->getRowLine(0);
}
/**
* Converts table into string
*
* @return string
*/
public function __toString()
{
return $this->getTableAsString();
}
/**
* Retrieves a hash iterator.
*
* @return Iterator
*/
public function getIterator()
{
return new ArrayIterator($this->getHash());
}
/**
* Pads string right.
*
* @param string $text Text to pad
* @param integer $length Length
*
* @return string
*/
protected function padRight($text, $length)
{
while ($length > mb_strlen($text, 'utf8')) {
$text = $text . ' ';
}
return $text;
}
}

42
vendor/behat/gherkin/src/Behat/Gherkin/Node/TaggedNodeInterface.php vendored

@ -1,42 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin\Node;
/**
* Gherkin tagged node interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface TaggedNodeInterface extends NodeInterface
{
/**
* Checks if node is tagged with tag.
*
* @param string $tag
*
* @return Boolean
*/
public function hasTag($tag);
/**
* Checks if node has tags (both inherited from feature and own).
*
* @return Boolean
*/
public function hasTags();
/**
* Returns node tags (including inherited from feature).
*
* @return string[]
*/
public function getTags();
}

699
vendor/behat/gherkin/src/Behat/Gherkin/Parser.php vendored

@ -1,699 +0,0 @@
<?php
/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Gherkin;
use Behat\Gherkin\Exception\LexerException;
use Behat\Gherkin\Exception\ParserException;
use Behat\Gherkin\Node\BackgroundNode;
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\OutlineNode;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\ScenarioInterface;
use Behat\Gherkin\Node\ScenarioNode;
use Behat\Gherkin\Node\StepNode;
use Behat\Gherkin\Node\TableNode;
/**
* Gherkin parser.
*
* $lexer = new Behat\Gherkin\Lexer($keywords);
* $parser = new Behat\Gherkin\Parser($lexer);
* $featuresArray = $parser->parse('/path/to/feature.feature');
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class Parser
{
private $lexer;
private $input;
private $file;
private $tags = array();
private $languageSpecifierLine;
/**
* Initializes parser.
*
* @param Lexer $lexer Lexer instance
*/
public function __construct(Lexer $lexer)
{
$this->lexer = $lexer;
}
/**
* Parses input & returns features array.
*
* @param string $input Gherkin string document
* @param string $file File name
*
* @return FeatureNode|null
*
* @throws ParserException
*/
public function parse($input, $file = null)
{
$this->languageSpecifierLine = null;
$this->input = $input;
$this->file = $file;
$this->tags = array();
try {
$this->lexer->analyse($this->input, 'en');
} catch (LexerException $e) {
throw new ParserException(
sprintf('Lexer exception "%s" thrown for file %s', $e->getMessage(), $file),
0,
$e
);
}
$feature = null;
while ('EOS' !== ($predicted = $this->predictTokenType())) {
$node = $this->parseExpression();
if (null === $node || "\n" === $node) {
continue;
}
if (!$feature && $node instanceof FeatureNode) {
$feature = $node;
continue;
}
if ($feature && $node instanceof FeatureNode) {
throw new ParserException(sprintf(
'Only one feature is allowed per feature file. But %s got multiple.',
$this->file
));
}
if (is_string($node)) {
throw new ParserException(sprintf(
'Expected Feature, but got text: "%s"%s',
$node,
$this->file ? ' in file: ' . $this->file : ''
));
}
if (!$node instanceof FeatureNode) {
throw new ParserException(sprintf(
'Expected Feature, but got %s on line: %d%s',
$node->getKeyword(),
$node->getLine(),
$this->file ? ' in file: ' . $this->file : ''
));
}
}
return $feature;
}
/**
* Returns next token if it's type equals to expected.
*
* @param string $type Token type
*
* @return array
*
* @throws Exception\ParserException
*/
protected function expectTokenType($type)
{
$types = (array) $type;
if (in_array($this->predictTokenType(), $types)) {
return $this->lexer->getAdvancedToken();
}
$token = $this->lexer->predictToken();
throw new ParserException(sprintf(
'Expected %s token, but got %s on line: %d%s',
implode(' or ', $types),
$this->predictTokenType(),
$token['line'],
$this->file ? ' in file: ' . $this->file : ''
));
}
/**
* Returns next token if it's type equals to expected.
*
* @param string $type Token type
*
* @return null|array
*/
protected function acceptTokenType($type)
{
if ($type !== $this->predictTokenType()) {
return null;
}
return $this->lexer->getAdvancedToken();
}
/**
* Returns next token type without real input reading (prediction).
*
* @return string
*/
protected function predictTokenType()
{
$token = $this->lexer->predictToken();
return $token['type'];
}
/**
* Parses current expression & returns Node.
*
* @return string|FeatureNode|BackgroundNode|ScenarioNode|OutlineNode|TableNode|StepNode
*
* @throws ParserException
*/
protected function parseExpression()
{
switch ($type = $this->predictTokenType()) {
case 'Feature':
return $this->parseFeature();
case 'Background':
return $this->parseBackground();
case 'Scenario':
return $this->parseScenario();
case 'Outline':
return $this->parseOutline();
case 'Examples':
return $this->parseExamples();
case 'TableRow':
return $this->parseTable();
case 'PyStringOp':
return $this->parsePyString();
case 'Step':
return $this->parseStep();
case 'Text':
return $this->parseText();
case 'Newline':
return $this->parseNewline();
case 'Tag':
return $this->parseTags();
case 'Comment':
return $this->parseComment();
case 'Language':
return $this->parseLanguage();
case 'EOS':
return '';
}
throw new ParserException(sprintf('Unknown token type: %s', $type));
}
/**
* Parses feature token & returns it's node.
*
* @return FeatureNode
*
* @throws ParserException
*/
protected function parseFeature()
{
$token = $this->expectTokenType('Feature');
$title = trim($token['value']) ?: null;
$description = null;
$tags = $this->popTags();
$background = null;
$scenarios = array();
$keyword = $token['keyword'];
$language = $this->lexer->getLanguage();
$file = $this->file;
$line = $token['line'];
// Parse description, background, scenarios & outlines
while ('EOS' !== $this->predictTokenType()) {
$node = $this->parseExpression();
if (is_string($node)) {
$text = preg_replace('/^\s{0,' . ($token['indent'] + 2) . '}|\s*$/', '', $node);
$description .= (null !== $description ? "\n" : '') . $text;
continue;
}
if (!$background && $node instanceof BackgroundNode) {
$background = $node;
continue;
}
if ($node instanceof ScenarioInterface) {
$scenarios[] = $node;
continue;
}
if ($background instanceof BackgroundNode && $node instanceof BackgroundNode) {
throw new ParserException(sprintf(
'Each Feature could have only one Background, but found multiple on lines %d and %d%s',
$background->getLine(),
$node->getLine(),
$this->file ? ' in file: ' . $this->file : ''
));
}
if (!$node instanceof ScenarioNode) {
throw new ParserException(sprintf(
'Expected Scenario, Outline or Background, but got %s on line: %d%s',
$node->getNodeType(),
$node->getLine(),
$this->file ? ' in file: ' . $this->file : ''
));
}
}
return new FeatureNode(
rtrim($title) ?: null,
rtrim($description) ?: null,
$tags,
$background,
$scenarios,
$keyword,
$language,
$file,
$line
);
}
/**
* Parses background token & returns it's node.
*
* @return BackgroundNode
*
* @throws ParserException
*/
protected function parseBackground()
{
$token = $this->expectTokenType('Background');
$title = trim($token['value']);
$keyword = $token['keyword'];
$line = $token['line'];
if (count($this->popTags())) {
throw new ParserException(sprintf(
'Background can not be tagged, but it is on line: %d%s',
$line,
$this->file ? ' in file: ' . $this->file : ''
));
}
// Parse description and steps
$steps = array();
$allowedTokenTypes = array('Step', 'Newline', 'Text', 'Comment');
while (in_array($this->predictTokenType(), $allowedTokenTypes)) {
$node = $this->parseExpression();
if ($node instanceof StepNode) {
$steps[] = $this->normalizeStepNodeKeywordType($node, $steps);
continue;
}
if (!count($steps) && is_string($node)) {
$text = preg_replace('/^\s{0,' . ($token['indent'] + 2) . '}|\s*$/', '', $node);
$title .= "\n" . $text;
continue;
}
if ("\n" === $node) {
continue;
}
if (is_string($node)) {
throw new ParserException(sprintf(
'Expected Step, but got text: "%s"%s',
$node,
$this->file ? ' in file: ' . $this->file : ''
));
}
if (!$node instanceof StepNode) {
throw new ParserException(sprintf(
'Expected Step, but got %s on line: %d%s',
$node->getNodeType(),
$node->getLine(),
$this->file ? ' in file: ' . $this->file : ''
));
}
}
return new BackgroundNode(rtrim($title) ?: null, $steps, $keyword, $line);
}
/**
* Parses scenario token & returns it's node.
*
* @return ScenarioNode
*
* @throws ParserException
*/
protected function parseScenario()
{
$token = $this->expectTokenType('Scenario');
$title = trim($token['value']);
$tags = $this->popTags();
$keyword = $token['keyword'];
$line = $token['line'];
// Parse description and steps
$steps = array();
while (in_array($this->predictTokenType(), array('Step', 'Newline', 'Text', 'Comment'))) {
$node = $this->parseExpression();
if ($node instanceof StepNode) {
$steps[] = $this->normalizeStepNodeKeywordType($node, $steps);
continue;
}
if (!count($steps) && is_string($node)) {
$text = preg_replace('/^\s{0,' . ($token['indent'] + 2) . '}|\s*$/', '', $node);
$title .= "\n" . $text;
continue;
}
if ("\n" === $node) {
continue;
}
if (is_string($node)) {
throw new ParserException(sprintf(
'Expected Step, but got text: "%s"%s',
$node,
$this->file ? ' in file: ' . $this->file : ''
));
}
if (!$node instanceof StepNode) {
throw new ParserException(sprintf(
'Expected Step, but got %s on line: %d%s',
$node->getNodeType(),
$node->getLine(),
$this->file ? ' in file: ' . $this->file : ''
));
}
}
return new ScenarioNode(rtrim($title) ?: null, $tags, $steps, $keyword, $line);
}
/**
* Parses scenario outline token & returns it's node.
*
* @return OutlineNode
*
* @throws ParserException
*/
protected function parseOutline()
{
$token = $this->expectTokenType('Outline');
$title = trim($token['value']);
$tags = $this->popTags();
$keyword = $token['keyword'];
$examples = null;
$line = $token['line'];
// Parse description, steps and examples
$steps = array();
while (in_array($this->predictTokenType(), array('Step', 'Examples', 'Newline', 'Text', 'Comment'))) {
$node = $this->parseExpression();
if ($node instanceof StepNode) {
$steps[] = $this->normalizeStepNodeKeywordType($node, $steps);
continue;
}
if ($node instanceof ExampleTableNode) {
$examples = $node;
continue;
}
if (!count($steps) && is_string($node)) {
$text = preg_replace('/^\s{0,' . ($token['indent'] + 2) . '}|\s*$/', '', $node);
$title .= "\n" . $text;
continue;
}
if ("\n" === $node) {
continue;
}
if (is_string($node)) {
throw new ParserException(sprintf(
'Expected Step or Examples table, but got text: "%s"%s',
$node,
$this->file ? ' in file: ' . $this->file : ''
));
}
if (!$node instanceof StepNode) {
throw new ParserException(sprintf(
'Expected Step or Examples table, but got %s on line: %d%s',
$node->getNodeType(),
$node->getLine(),
$this->file ? ' in file: ' . $this->file : ''
));
}
}
if (null === $examples) {
throw new ParserException(sprintf(
'Outline should have examples table, but got none for outline "%s" on line: %d%s',
rtrim($title),
$line,
$this->file ? ' in file: ' . $this->file : ''
));
}
return new OutlineNode(rtrim($title) ?: null, $tags, $steps, $examples, $keyword, $line);
}
/**
* Parses step token & returns it's node.
*
* @return StepNode
*/
protected function parseStep()
{
$token = $this->expectTokenType('Step');
$keyword = $token['value'];
$keywordType = $token['keyword_type'];
$text = trim($token['text']);
$line = $token['line'];
$arguments = array();
while (in_array($predicted = $this->predictTokenType(), array('PyStringOp', 'TableRow', 'Newline', 'Comment'))) {
if ('Comment' === $predicted || 'Newline' === $predicted) {
$this->acceptTokenType($predicted);
continue;
}
$node = $this->parseExpression();
if ($node instanceof PyStringNode || $node instanceof TableNode) {
$arguments[] = $node;
}
}
return new StepNode($keyword, $text, $arguments, $line, $keywordType);
}
/**
* Parses examples table node.
*
* @return ExampleTableNode
*/
protected function parseExamples()
{
$token = $this->expectTokenType('Examples');
$keyword = $token['keyword'];
return new ExampleTableNode($this->parseTableRows(), $keyword);
}
/**
* Parses table token & returns it's node.
*
* @return TableNode
*/
protected function parseTable()
{
return new TableNode($this->parseTableRows());
}
/**
* Parses PyString token & returns it's node.
*
* @return PyStringNode
*/
protected function parsePyString()
{
$token = $this->expectTokenType('PyStringOp');
$line = $token['line'];
$strings = array();
while ('PyStringOp' !== ($predicted = $this->predictTokenType()) && 'Text' === $predicted) {
$token = $this->expectTokenType('Text');
$strings[] = $token['value'];
}
$this->expectTokenType('PyStringOp');
return new PyStringNode($strings, $line);
}
/**
* Parses tags.
*
* @return BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
*/
protected function parseTags()
{
$token = $this->expectTokenType('Tag');
$this->tags = array_merge($this->tags, $token['tags']);
return $this->parseExpression();
}
/**
* Returns current set of tags and clears tag buffer.
*
* @return array
*/
protected function popTags()
{
$tags = $this->tags;
$this->tags = array();
return $tags;
}
/**
* Parses next text line & returns it.
*
* @return string
*/
protected function parseText()
{
$token = $this->expectTokenType('Text');
return $token['value'];
}
/**
* Parses next newline & returns \n.
*
* @return string
*/
protected function parseNewline()
{
$this->expectTokenType('Newline');
return "\n";
}
/**
* Parses next comment token & returns it's string content.
*
* @return BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
*/
protected function parseComment()
{
$this->expectTokenType('Comment');
return $this->parseExpression();
}
/**
* Parses language block and updates lexer configuration based on it.
*
* @return BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
*
* @throws ParserException
*/
protected function parseLanguage()
{
$token = $this->expectTokenType('Language');
if (null === $this->languageSpecifierLine) {
$this->lexer->analyse($this->input, $token['value']);
$this->languageSpecifierLine = $token['line'];
} elseif ($token['line'] !== $this->languageSpecifierLine) {
throw new ParserException(sprintf(
'Ambiguous language specifiers on lines: %d and %d%s',
$this->languageSpecifierLine,
$token['line'],
$this->file ? ' in file: ' . $this->file : ''
));
}
return $this->parseExpression();
}
/**
* Parses the rows of a table
*
* @return string[][]
*/
private function parseTableRows()
{
$table = array();
while (in_array($predicted = $this->predictTokenType(), array('TableRow', 'Newline', 'Comment'))) {
if ('Comment' === $predicted || 'Newline' === $predicted) {
$this->acceptTokenType($predicted);
continue;
}
$token = $this->expectTokenType('TableRow');
$table[$token['line']] = $token['columns'];
}
return $table;
}
/**
* Changes step node type for types But, And to type of previous step if it exists else sets to Given
*
* @param StepNode $node
* @param StepNode[] $steps
* @return StepNode
*/
private function normalizeStepNodeKeywordType(StepNode $node, array $steps = array())
{
if (in_array($node->getKeywordType(), array('And', 'But'))) {
if (($prev = end($steps))) {
$keywordType = $prev->getKeywordType();
} else {
$keywordType = 'Given';
}
$node = new StepNode(
$node->getKeyword(),
$node->getText(),
$node->getArguments(),
$node->getLine(),
$keywordType
);
}
return $node;
}
}

75
vendor/behat/gherkin/tests/Behat/Gherkin/Cache/FileCacheTest.php vendored

@ -1,75 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Cache;
use Behat\Gherkin\Cache\FileCache;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioNode;
use Behat\Gherkin\Gherkin;
class FileCacheTest extends \PHPUnit_Framework_TestCase
{
private $path;
private $cache;
public function testIsFreshWhenThereIsNoFile()
{
$this->assertFalse($this->cache->isFresh('unexisting', time() + 100));
}
public function testIsFreshOnFreshFile()
{
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
$this->cache->write('some_path', $feature);
$this->assertFalse($this->cache->isFresh('some_path', time() + 100));
}
public function testIsFreshOnOutdated()
{
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
$this->cache->write('some_path', $feature);
$this->assertTrue($this->cache->isFresh('some_path', time() - 100));
}
public function testCacheAndRead()
{
$scenarios = array(new ScenarioNode('Some scenario', array(), array(), null, null));
$feature = new FeatureNode('Some feature', 'some description', array(), null, $scenarios, null, null, null, null);
$this->cache->write('some_feature', $feature);
$featureRead = $this->cache->read('some_feature');
$this->assertEquals($feature, $featureRead);
}
public function testBrokenCacheRead()
{
$this->setExpectedException('Behat\Gherkin\Exception\CacheException');
touch($this->path . '/v' . Gherkin::VERSION . '/' . md5('broken_feature') . '.feature.cache');
$this->cache->read('broken_feature');
}
public function testUnwriteableCacheDir()
{
$this->setExpectedException('Behat\Gherkin\Exception\CacheException');
new FileCache('/dev/null/gherkin-test');
}
protected function setUp()
{
$this->cache = new FileCache($this->path = sys_get_temp_dir() . '/gherkin-test');
}
protected function tearDown()
{
foreach (glob($this->path . '/*.feature.cache') as $file) {
unlink((string) $file);
}
}
}

51
vendor/behat/gherkin/tests/Behat/Gherkin/Cache/MemoryCacheTest.php vendored

@ -1,51 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Cache;
use Behat\Gherkin\Cache\MemoryCache;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioNode;
class MemoryCacheTest extends \PHPUnit_Framework_TestCase
{
private $cache;
public function testIsFreshWhenThereIsNoFile()
{
$this->assertFalse($this->cache->isFresh('unexisting', time() + 100));
}
public function testIsFreshOnFreshFile()
{
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
$this->cache->write('some_path', $feature);
$this->assertFalse($this->cache->isFresh('some_path', time() + 100));
}
public function testIsFreshOnOutdated()
{
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
$this->cache->write('some_path', $feature);
$this->assertTrue($this->cache->isFresh('some_path', time() - 100));
}
public function testCacheAndRead()
{
$scenarios = array(new ScenarioNode('Some scenario', array(), array(), null, null));
$feature = new FeatureNode('Some feature', 'some description', array(), null, $scenarios, null, null, null, null);
$this->cache->write('some_feature', $feature);
$featureRead = $this->cache->read('some_feature');
$this->assertEquals($feature, $featureRead);
}
protected function setUp()
{
$this->cache = new MemoryCache();
}
}

64
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/FilterTest.php vendored

@ -1,64 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Filter;
use Behat\Gherkin\Keywords\ArrayKeywords;
use Behat\Gherkin\Lexer;
use Behat\Gherkin\Parser;
abstract class FilterTest extends \PHPUnit_Framework_TestCase
{
protected function getParser()
{
return new Parser(
new Lexer(
new ArrayKeywords(array(
'en' => array(
'feature' => 'Feature',
'background' => 'Background',
'scenario' => 'Scenario',
'scenario_outline' => 'Scenario Outline|Scenario Template',
'examples' => 'Examples|Scenarios',
'given' => 'Given',
'when' => 'When',
'then' => 'Then',
'and' => 'And',
'but' => 'But'
)
))
)
);
}
protected function getGherkinFeature()
{
return <<<GHERKIN
Feature: Long feature with outline
Scenario: Scenario#1
Given initial step
When action occurs
Then outcomes should be visible
Scenario: Scenario#2
Given initial step
And another initial step
When action occurs
Then outcomes should be visible
Scenario Outline: Scenario#3
When <action> occurs
Then <outcome> should be visible
Examples:
| action | outcome |
| act#1 | out#1 |
| act#2 | out#2 |
| act#3 | out#3 |
GHERKIN;
}
protected function getParsedFeature()
{
return $this->getParser()->parse($this->getGherkinFeature());
}
}

0
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/Fixtures/full/file1 vendored

0
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/Fixtures/full/file2 vendored

0
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/Fixtures/full_path/file1 vendored

103
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/LineFilterTest.php vendored

@ -1,103 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Filter;
use Behat\Gherkin\Filter\LineFilter;
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\OutlineNode;
use Behat\Gherkin\Node\ScenarioNode;
class LineFilterTest extends FilterTest
{
public function testIsFeatureMatchFilter()
{
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1);
$filter = new LineFilter(1);
$this->assertTrue($filter->isFeatureMatch($feature));
$filter = new LineFilter(2);
$this->assertFalse($filter->isFeatureMatch($feature));
$filter = new LineFilter(3);
$this->assertFalse($filter->isFeatureMatch($feature));
}
public function testIsScenarioMatchFilter()
{
$scenario = new ScenarioNode(null, array(), array(), null, 2);
$filter = new LineFilter(2);
$this->assertTrue($filter->isScenarioMatch($scenario));
$filter = new LineFilter(1);
$this->assertFalse($filter->isScenarioMatch($scenario));
$filter = new LineFilter(5);
$this->assertFalse($filter->isScenarioMatch($scenario));
$outline = new OutlineNode(null, array(), array(), new ExampleTableNode(array(), null), null, 20);
$filter = new LineFilter(5);
$this->assertFalse($filter->isScenarioMatch($outline));
$filter = new LineFilter(20);
$this->assertTrue($filter->isScenarioMatch($outline));
}
public function testFilterFeatureScenario()
{
$filter = new LineFilter(2);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#1', $scenarios[0]->getTitle());
$filter = new LineFilter(7);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#2', $scenarios[0]->getTitle());
$filter = new LineFilter(5);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(0, $scenarios = $feature->getScenarios());
}
public function testFilterFeatureOutline()
{
$filter = new LineFilter(13);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#3', $scenarios[0]->getTitle());
$this->assertCount(4, $scenarios[0]->getExampleTable()->getRows());
$filter = new LineFilter(19);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#3', $scenarios[0]->getTitle());
$this->assertCount(2, $scenarios[0]->getExampleTable()->getRows());
$this->assertSame(array(
array('action', 'outcome'),
array('act#1', 'out#1'),
), $scenarios[0]->getExampleTable()->getRows());
$filter = new LineFilter(21);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#3', $scenarios[0]->getTitle());
$this->assertCount(2, $scenarios[0]->getExampleTable()->getRows());
$this->assertSame(array(
array('action', 'outcome'),
array('act#3', 'out#3'),
), $scenarios[0]->getExampleTable()->getRows());
$filter = new LineFilter(18);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#3', $scenarios[0]->getTitle());
$this->assertCount(1, $scenarios[0]->getExampleTable()->getRows());
$this->assertSame(array(
array('action', 'outcome'),
), $scenarios[0]->getExampleTable()->getRows());
}
}

101
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/LineRangeFilterTest.php vendored

@ -1,101 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Filter;
use Behat\Gherkin\Filter\LineRangeFilter;
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\OutlineNode;
use Behat\Gherkin\Node\ScenarioNode;
class LineRangeFilterTest extends FilterTest
{
public function featureLineRangeProvider()
{
return array(
array('1', '1', true),
array('1', '2', true),
array('1', '*', true),
array('2', '2', false),
array('2', '*', false)
);
}
/**
* @dataProvider featureLineRangeProvider
*/
public function testIsFeatureMatchFilter($filterMinLine, $filterMaxLine, $expected)
{
$feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1);
$filter = new LineRangeFilter($filterMinLine, $filterMaxLine);
$this->assertSame($expected, $filter->isFeatureMatch($feature));
}
public function scenarioLineRangeProvider()
{
return array(
array('1', '2', 1),
array('1', '*', 2),
array('2', '2', 1),
array('2', '*', 2),
array('3', '3', 1),
array('3', '*', 1),
array('1', '1', 0),
array('4', '4', 0),
array('4', '*', 0)
);
}
/**
* @dataProvider scenarioLineRangeProvider
*/
public function testIsScenarioMatchFilter($filterMinLine, $filterMaxLine, $expectedNumberOfMatches)
{
$scenario = new ScenarioNode(null, array(), array(), null, 2);
$outline = new OutlineNode(null, array(), array(), new ExampleTableNode(array(), null), null, 3);
$filter = new LineRangeFilter($filterMinLine, $filterMaxLine);
$this->assertEquals(
$expectedNumberOfMatches,
intval($filter->isScenarioMatch($scenario)) + intval($filter->isScenarioMatch($outline))
);
}
public function testFilterFeatureScenario()
{
$filter = new LineRangeFilter(1, 3);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#1', $scenarios[0]->getTitle());
$filter = new LineRangeFilter(5, 9);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#2', $scenarios[0]->getTitle());
$filter = new LineRangeFilter(5, 6);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(0, $scenarios = $feature->getScenarios());
}
public function testFilterFeatureOutline()
{
$filter = new LineRangeFilter(12, 14);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#3', $scenarios[0]->getTitle());
$this->assertCount(1, $scenarios[0]->getExampleTable()->getRows());
$filter = new LineRangeFilter(15, 20);
$feature = $filter->filterFeature($this->getParsedFeature());
$this->assertCount(1, $scenarios = $feature->getScenarios());
$this->assertSame('Scenario#3', $scenarios[0]->getTitle());
$this->assertCount(3, $scenarios[0]->getExampleTable()->getRows());
$this->assertSame(array(
array('action', 'outcome'),
array('act#1', 'out#1'),
array('act#2', 'out#2'),
), $scenarios[0]->getExampleTable()->getRows());
}
}

79
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/NameFilterTest.php vendored

@ -1,79 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Filter;
use Behat\Gherkin\Filter\NameFilter;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\ScenarioNode;
class NameFilterTest extends \PHPUnit_Framework_TestCase
{
public function testFilterFeature()
{
$feature = new FeatureNode('feature1', null, array(), null, array(), null, null, null, 1);
$filter = new NameFilter('feature1');
$this->assertSame($feature, $filter->filterFeature($feature));
$scenarios = array(
new ScenarioNode('scenario1', array(), array(), null, 2),
$matchedScenario = new ScenarioNode('scenario2', array(), array(), null, 4)
);
$feature = new FeatureNode('feature1', null, array(), null, $scenarios, null, null, null, 1);
$filter = new NameFilter('scenario2');
$filteredFeature = $filter->filterFeature($feature);
$this->assertSame(array($matchedScenario), $filteredFeature->getScenarios());
}
public function testIsFeatureMatchFilter()
{
$feature = new FeatureNode('random feature title', null, array(), null, array(), null, null, null, 1);
$filter = new NameFilter('feature1');
$this->assertFalse($filter->isFeatureMatch($feature));
$feature = new FeatureNode('feature1', null, array(), null, array(), null, null, null, 1);
$this->assertTrue($filter->isFeatureMatch($feature));
$feature = new FeatureNode('feature1 title', null, array(), null, array(), null, null, null, 1);
$this->assertTrue($filter->isFeatureMatch($feature));
$feature = new FeatureNode('some feature1 title', null, array(), null, array(), null, null, null, 1);
$this->assertTrue($filter->isFeatureMatch($feature));
$feature = new FeatureNode('some feature title', null, array(), null, array(), null, null, null, 1);
$this->assertFalse($filter->isFeatureMatch($feature));
$filter = new NameFilter('/fea.ure/');
$this->assertTrue($filter->isFeatureMatch($feature));
$feature = new FeatureNode('some feaSure title', null, array(), null, array(), null, null, null, 1);
$this->assertTrue($filter->isFeatureMatch($feature));
$feature = new FeatureNode('some feture title', null, array(), null, array(), null, null, null, 1);
$this->assertFalse($filter->isFeatureMatch($feature));
}
public function testIsScenarioMatchFilter()
{
$filter = new NameFilter('scenario1');
$scenario = new ScenarioNode('UNKNOWN', array(), array(), null, 2);
$this->assertFalse($filter->isScenarioMatch($scenario));
$scenario = new ScenarioNode('scenario1', array(), array(), null, 2);
$this->assertTrue($filter->isScenarioMatch($scenario));
$scenario = new ScenarioNode('scenario1 title', array(), array(), null, 2);
$this->assertTrue($filter->isScenarioMatch($scenario));
$scenario = new ScenarioNode('some scenario title', array(), array(), null, 2);
$this->assertFalse($filter->isScenarioMatch($scenario));
$filter = new NameFilter('/sce.ario/');
$this->assertTrue($filter->isScenarioMatch($scenario));
$filter = new NameFilter('/scen.rio/');
$this->assertTrue($filter->isScenarioMatch($scenario));
}
}

34
vendor/behat/gherkin/tests/Behat/Gherkin/Filter/NarrativeFilterTest.php vendored

@ -1,34 +0,0 @@
<?php
namespace Tests\Behat\Gherkin\Filter;
use Behat\Gherkin\Filter\NarrativeFilter;
use Behat\Gherkin\Node\FeatureNode;
class NarrativeFilterTest extends FilterTest
{
public function testIsFeatureMatchFilter()
{
$description = <<<NAR
In order to be able to read news in my own language
As a french user
I need to be able to switch website language to french
NAR;
$feature = new FeatureNode(null, $description, array(), null, array(), null, null, null, 1);
$filter = new NarrativeFilter('/as (?:a|an) french user/');
$this->assertFalse($filter->isFeatureMatch($feature));
$filter = new NarrativeFilter('/as (?:a|an) french user/i');
$this->assertTrue($filter->isFeatureMatch($feature));
$filter = new NarrativeFilter('/french .*/');
$this->assertTrue($filter->isFeatureMatch($feature));
$filter = new NarrativeFilter('/^french/');
$this->assertFalse($filter->isFeatureMatch($feature));
$filter = new NarrativeFilter('/user$/');
$this->assertFalse($filter->isFeatureMatch($feature));
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save