From 34f542cfe4be1417b9772b49ff323a4245a85110 Mon Sep 17 00:00:00 2001 From: spleshka Date: Sat, 31 Mar 2018 13:21:53 +0300 Subject: [PATCH 1/7] #6 Added initial support of make files to the project. --- .env.default | 7 + .gitignore | 12 +- Makefile | 168 +++++++++++++++++ README.md | 59 ++---- .../3b111b33-7654-4933-a072-ea3c56ad70bd.json | 93 --------- .../5bda671a-dec8-4764-aeb0-a70e76fdeefa.json | 93 --------- .../6c6c8f0c-81a1-4fce-93e6-0330f87b3162.json | 88 --------- .../falcon_development.install | 58 +++++- .../web/sites/default/default.settings.php | 56 +++++- .../web/sites/default/settings.local.php | 18 +- backend-donations/web/sites/services.yml | 19 ++ .../9fca84d4-3c5c-44e9-9b38-0191f0d88969.json | 93 --------- .../dbb568e9-32f7-4a7b-a65b-bb6f636d8963.json | 83 -------- .../falcon_development.install | 58 +++++- .../web/sites/default/settings.local.php | 18 +- docker-compose-mac.yml | 177 ------------------ docker-compose.override.yml | 95 ---------- docker-sync.yml | 19 -- docker/docker-compose.override.default.yml | 103 ++++++++++ .../docker-compose.yml | 59 +++--- 20 files changed, 531 insertions(+), 845 deletions(-) create mode 100644 .env.default create mode 100644 Makefile delete mode 100644 backend-donations/web/modules/falcon/falcon_demo_content/content/user/3b111b33-7654-4933-a072-ea3c56ad70bd.json delete mode 100644 backend-donations/web/modules/falcon/falcon_demo_content/content/user/5bda671a-dec8-4764-aeb0-a70e76fdeefa.json delete mode 100644 backend-donations/web/modules/falcon/falcon_demo_content/content/user/6c6c8f0c-81a1-4fce-93e6-0330f87b3162.json delete mode 100644 backend-gifts/web/modules/falcon/falcon_demo_content/content/user/9fca84d4-3c5c-44e9-9b38-0191f0d88969.json delete mode 100644 backend-gifts/web/modules/falcon/falcon_demo_content/content/user/dbb568e9-32f7-4a7b-a65b-bb6f636d8963.json delete mode 100644 docker-compose-mac.yml delete mode 100644 docker-compose.override.yml delete mode 100644 docker-sync.yml create mode 100644 docker/docker-compose.override.default.yml rename docker-compose.yml => docker/docker-compose.yml (73%) diff --git a/.env.default b/.env.default new file mode 100644 index 0000000..6156614 --- /dev/null +++ b/.env.default @@ -0,0 +1,7 @@ +# Docker-compose environment variables - see https://docs.docker.com/compose/reference/envvars/ +COMPOSE_FILE=./docker/docker-compose.yml:./docker/docker-compose.override.yml +COMPOSE_PROJECT_NAME=falcon + +# Base URL for local development. +# All microservices are subdomains to this one. +PROJECT_BASE_URL=flc.local diff --git a/.gitignore b/.gitignore index 939b05d..8a5d9c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ -# IDE files +# PHPStorm folder. .idea -dev -# Ignoring any composer files inside of the root (if any). -vendor +# Mac artifacts. .DS_Store + +# Locally generated env file. +.env + +# Locally generated docker file with overrides. +docker/docker-compose.override.yml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7439b05 --- /dev/null +++ b/Makefile @@ -0,0 +1,168 @@ +.PHONY: falcon falcon-install falcon-update drush + +# Make sure the local file with docker-compose overrides exist. +$(shell ! test -e \.\/docker\/docker-compose\.override\.yml && cat \.\/docker\/docker-compose\.override\.default\.yml > \.\/docker\/docker-compose\.override\.yml) + +# Create a .env file if not exists and include default env variables. +$(shell ! test -e \.env && cat \.env.default > \.env) + +# Make all variables from the file available here. +include .env + +# Define two users for with different permissions within the php container. +php = docker-compose exec --user=82:82 $(firstword ${1}) sh -c "$(filter-out $(firstword ${1}), ${1})" +php-wodby = docker-compose exec $(firstword ${1}) sh -c "$(filter-out $(firstword ${1}), ${1})" + +falcon: + # Remove the first argument from the list of make commands. + $(eval COMMAND := $(filter-out $@,$(MAKECMDGOALS))) + @if [ "$(COMMAND)" = "install" ]; then\ + $(MAKE) -s falcon-install;\ + fi + @if [ "$(COMMAND)" = "update" ]; then\ + $(MAKE) -s falcon-update;\ + fi + @if [ "$(COMMAND)" != "update" ] && [ "$(COMMAND)" != "install" ]; then\ + echo "Command was not found. Try 'make falcon install' or 'make falcon update' instead." ;\ + fi + +drush: + # Remove the first argument from the list of make commands. + $(eval ARGS := $(filter-out $@,$(MAKECMDGOALS))) + @echo Target is \"$(firstword $(ARGS))\" + @echo Executing \"drush -r /var/www/html/web $(filter-out $(firstword $(ARGS)), $(ARGS)) --yes\" + $(call php, $(filter $(firstword $(ARGS)), $(ARGS)) drush -r /var/www/html/web $(filter-out $(firstword $(ARGS)), $(ARGS)) --yes) + +shell: + # Remove the first argument from the list of make commands. + $(eval ARGS := $(filter-out $@,$(MAKECMDGOALS))) + @echo Target is \"$(firstword $(ARGS))\" + @echo Executing \"shell $(filter-out $(firstword $(ARGS)), $(ARGS))\" + $(call php, $(filter $(firstword $(ARGS)), $(ARGS)) $(filter-out $(firstword $(ARGS)), $(ARGS))) + +down: + @docker-compose down --remove-orphans + +up: + @docker-compose up -d --remove-orphans + +####################################### +## Internal command. +## Invoked from "make falcon install". +## +## Builds the falcon from the buttom up. +####################################### + +falcon-install: + @echo "Installing Falcon from the bottom up..." + + @echo "Setting git config to ignore local files chmod..." + @git config core.fileMode false + + @echo "###############################" + @echo "# Preparing Docker containers #" + @echo "###############################" + + @echo "Making sure Docker is not running..." + @docker-compose down --remove-orphans + @echo "Fetching Docker images..." + docker-compose pull --parallel + + @echo "############################" + @echo "# Preparing Gifts Frontend #" + @echo "############################" + + @echo "Installing yarn dependencies for Gifts Frontend..." + @docker-compose run --no-deps fe_gifts yarn install + + @echo "###########################" + @echo "# Preparing Main Frontend #" + @echo "###########################" + + @echo "Installing yarn dependencies for Main Frontend..." + @docker-compose run --no-deps fe_main yarn install + + # Spinning up all containers now. + docker-compose up -d --remove-orphans + + @echo "#####################" + @echo "# Preparing API BUS #" + @echo "#####################" + + @echo "Installing composer dependencies for API Bus..." + -$(call php-wodby, api_bus composer install) + @echo "Copying default local config file for API bus into the adjustable local config..." + @cp ./backend-api-bus/src/config/local.default.php ./backend-api-bus/src/config/local.php + + @echo "###########################" + @echo "# Preparing Gifts backend #" + @echo "###########################" + + @echo "Installing composer dependencies for Gifts Backend..." + -$(call php-wodby, be_gifts composer install) + #@echo "Setting the right permissions for local settings.file..." + #-$(call php-wodby, be_gifts chmod 0777 web/sites/default/settings.php) + @echo "Installing Gifts site..." + $(MAKE) -s drush be_gifts site-install config_installer + @echo "Installing the module to import demo content..." + $(MAKE) -s drush be_gifts en falcon_demo_content + @echo "Disabling unnecessary modules after demo content import..." + $(MAKE) -s drush be_gifts pmu falcon_demo_content default_content better_normalizers hal + + @echo "###############################" + @echo "# Preparing Donations backend #" + @echo "###############################" + + @echo "Installing composer dependencies for Donations Backend..." + -$(call php-wodby, be_donations composer install) + #@echo "Setting the right permissions for local settings.file..." + #-$(call php-wodby, be_donations chmod 0777 web/sites/default/settings.php) + @echo "Installing Donations site..." + $(MAKE) -s drush be_donations site-install config_installer + @echo "Installing the module to import demo content..." + $(MAKE) -s drush be_donations en falcon_demo_content + @echo "Disabling unnecessary modules after demo content import..." + $(MAKE) -s drush be_donations pmu falcon_demo_content default_content better_normalizers hal + +####################################### +## Internal command. +## Invoked from "make falcon update". +## +## Brings the falcon up to date with latest changes. +####################################### + +falcon-update: + @echo "Updating the code from the git remote branch..." + @git pull origin $(git rev-parse --abbrev-ref HEAD) + + # Frontend restart is not needed, because dontainers restart will + # trigger yarn install anyway. + @echo "Restarting Docker containers..." + @docker-compose down --remove-orphans + docker-compose up -d --remove-orphans + + @echo "Updating composer dependencies for Donations backend..." + -$(call php-wodby, be_donations composer install) + @echo "Updating cache on Donations backend..." + $(MAKE) -s drush be_donations cr + @echo "Applying database updates on Donations backend..." + $(MAKE) -s drush be_donations updb + @echo "Importing configs into Donations backend..." + $(MAKE) -s drush be_donations cim + @echo "Applying entity updates on Donations backend..." + $(MAKE) -s drush be_donations entup + + @echo "Updating composer dependencies for Gifts backend..." + -$(call php-wodby, be_gifts composer install) + @echo "Updating cache on Gifts backend..." + $(MAKE) -s drush be_gifts cr + @echo "Applying database updates on Gifts backend..." + $(MAKE) -s drush be_gifts updb + @echo "Importing configs into Gifts backend..." + $(MAKE) -s drush be_gifts cim + @echo "Applying entity updates on Gifts backend..." + $(MAKE) -s drush be_gifts entup + +# https://stackoverflow.com/a/6273809/1826109 +%: + @: diff --git a/README.md b/README.md index f5a7a11..f2c7afe 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,32 @@ [![CircleCI](https://circleci.com/gh/systemseed/falcon.svg?style=shield&circle-token=7736ea9ff7656c7025fb3727b27a4f9d0be0857d)](https://circleci.com/gh/systemseed/falcon) -# Falcon - -This is the main repository for Falcon. You should start your journey by cloning this repo and following the instructions in this file. - -## Understanding the project's structure - -This repo contains Platform.sh multi-app project. -You'll find more info about it at their [documentation](https://docs.platform.sh/configuration/app/multi-app.html). - - ## Getting started - -1. Download this repo to your local environment: + +1. Add the following lines to your hosts file: ``` - git clone git@github.com:systemseed/falcon.git + 127.0.0.1 gifts.flc.local + 127.0.0.1 main.flc.local + 127.0.0.1 api.flc.local + 127.0.0.1 gifts.api.flc.local + 127.0.0.1 pma.gifts.api.flc.local + 127.0.0.1 donations.api.flc.local + 127.0.0.1 pma.donations.api.flc.local ``` + +2. Download this repository to your local environment: -2. Install [Platform.sh CLI](https://github.com/platformsh/platformsh-cli): - - ``` - curl -sS https://platform.sh/cli/installer | php ``` - - Don't forget to authenticate after the installation. CLI docs to the rescue. - -3. Run bash script `./local-prepare.sh` in the git root to prepare all necessary dependencies & local environment. - -4. Add the following lines to your hosts file: - - ``` - 127.0.0.1 main.flc.local gifts.flc.local api.flc.local gifts.api.flc.local donations.api.flc.local # FALCON installation + git clone git@github.com:systemseed/falcon.git ``` -5. Run `docker-compose up -d`. Profit! - -## Accessing web sites locally + +3. Run `make falcon install` in the root of repository. Profit! -### Gifts Frontend +4. TODO -[http://gifts.flc.local](http://gifts.flc.local) -### Gifts Backend -[http://gifts.api.flc.local](http://gifts.api.flc.local) -### Donations Backend - -[http://donations.api.flc.local](http://donations.api.flc.local) - -### API Bus - -[http://api.flc.local](http://api.flc.local) ## Running ESLint for FrontEnd apps @@ -61,7 +36,3 @@ docker-compose run fe_gifts sh ./node_modules/.bin/eslint ./src ``` -## Shutting down the environments - -To shut the environment run `docker-compose stop`. - diff --git a/backend-donations/web/modules/falcon/falcon_demo_content/content/user/3b111b33-7654-4933-a072-ea3c56ad70bd.json b/backend-donations/web/modules/falcon/falcon_demo_content/content/user/3b111b33-7654-4933-a072-ea3c56ad70bd.json deleted file mode 100644 index f85778e..0000000 --- a/backend-donations/web/modules/falcon/falcon_demo_content/content/user/3b111b33-7654-4933-a072-ea3c56ad70bd.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "_links": { - "self": { - "href": "http:\/\/default\/user\/18?_format=hal_json" - }, - "type": { - "href": "http:\/\/drupal.org\/rest\/type\/user\/user" - } - }, - "uid": [ - { - "value": 18 - } - ], - "uuid": [ - { - "value": "3b111b33-7654-4933-a072-ea3c56ad70bd" - } - ], - "langcode": [ - { - "value": "en", - "lang": "en" - } - ], - "preferred_langcode": [ - { - "value": "en" - } - ], - "preferred_admin_langcode": [ - { - "value": "en" - } - ], - "name": [ - { - "value": "gifts_manager.test" - } - ], - "mail": [ - { - "value": "flc.gifts_manager-test@systemseed.com" - } - ], - "timezone": [ - { - "value": "UTC" - } - ], - "status": [ - { - "value": true - } - ], - "created": [ - { - "value": 1493111825 - } - ], - "changed": [ - { - "value": 1509381343, - "lang": "en" - } - ], - "access": [ - { - "value": 1496327687 - } - ], - "login": [ - { - "value": 1496078514 - } - ], - "init": [ - { - "value": "flc.gifts_manager-test@systemseed.com" - } - ], - "roles": [ - { - "target_id": "gifts_manager" - } - ], - "default_langcode": [ - { - "value": true, - "lang": "en" - } - ] -} \ No newline at end of file diff --git a/backend-donations/web/modules/falcon/falcon_demo_content/content/user/5bda671a-dec8-4764-aeb0-a70e76fdeefa.json b/backend-donations/web/modules/falcon/falcon_demo_content/content/user/5bda671a-dec8-4764-aeb0-a70e76fdeefa.json deleted file mode 100644 index fdb4705..0000000 --- a/backend-donations/web/modules/falcon/falcon_demo_content/content/user/5bda671a-dec8-4764-aeb0-a70e76fdeefa.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "_links": { - "self": { - "href": "http:\/\/default\/user\/14?_format=hal_json" - }, - "type": { - "href": "http:\/\/drupal.org\/rest\/type\/user\/user" - } - }, - "uid": [ - { - "value": 14 - } - ], - "uuid": [ - { - "value": "5bda671a-dec8-4764-aeb0-a70e76fdeefa" - } - ], - "langcode": [ - { - "value": "en", - "lang": "en" - } - ], - "preferred_langcode": [ - { - "value": "en" - } - ], - "preferred_admin_langcode": [ - { - "value": "en" - } - ], - "name": [ - { - "value": "api.gifts_manager" - } - ], - "mail": [ - { - "value": "flc.api.gifts_manager-test@systemseed.com" - } - ], - "timezone": [ - { - "value": "UTC" - } - ], - "status": [ - { - "value": false - } - ], - "created": [ - { - "value": 1491678205 - } - ], - "changed": [ - { - "value": 1497017261, - "lang": "en" - } - ], - "access": [ - { - "value": 1509112832 - } - ], - "login": [ - { - "value": 0 - } - ], - "init": [ - { - "value": "flc.api.gifts_manager-test@systemseed.com" - } - ], - "roles": [ - { - "target_id": "gifts_manager" - } - ], - "default_langcode": [ - { - "value": true, - "lang": "en" - } - ] -} \ No newline at end of file diff --git a/backend-donations/web/modules/falcon/falcon_demo_content/content/user/6c6c8f0c-81a1-4fce-93e6-0330f87b3162.json b/backend-donations/web/modules/falcon/falcon_demo_content/content/user/6c6c8f0c-81a1-4fce-93e6-0330f87b3162.json deleted file mode 100644 index 0973618..0000000 --- a/backend-donations/web/modules/falcon/falcon_demo_content/content/user/6c6c8f0c-81a1-4fce-93e6-0330f87b3162.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "_links": { - "self": { - "href": "http:\/\/default\/user\/9?_format=hal_json" - }, - "type": { - "href": "http:\/\/drupal.org\/rest\/type\/user\/user" - } - }, - "uid": [ - { - "value": 9 - } - ], - "uuid": [ - { - "value": "6c6c8f0c-81a1-4fce-93e6-0330f87b3162" - } - ], - "langcode": [ - { - "value": "en", - "lang": "en" - } - ], - "preferred_langcode": [ - { - "value": "en" - } - ], - "preferred_admin_langcode": [ - { - "value": "en" - } - ], - "name": [ - { - "value": "administrator.test" - } - ], - "mail": [ - { - "value": "flc.administrator-test@systemseed.com" - } - ], - "timezone": [ - { - "value": "UTC" - } - ], - "status": [ - { - "value": true - } - ], - "created": [ - { - "value": 1489059956 - } - ], - "changed": [ - { - "value": 1509381343, - "lang": "en" - } - ], - "access": [ - { - "value": 1497015582 - } - ], - "login": [ - { - "value": 1497015582 - } - ], - "roles": [ - { - "target_id": "administrator" - } - ], - "default_langcode": [ - { - "value": true, - "lang": "en" - } - ] -} \ No newline at end of file diff --git a/backend-donations/web/modules/falcon/falcon_development/falcon_development.install b/backend-donations/web/modules/falcon/falcon_development/falcon_development.install index 786e18d..b8e210c 100644 --- a/backend-donations/web/modules/falcon/falcon_development/falcon_development.install +++ b/backend-donations/web/modules/falcon/falcon_development/falcon_development.install @@ -1,26 +1,72 @@ id() == 'anonymous') { + continue; + } + + $username = $role->id() . '.test'; + /* @var $account \Drupal\user\Entity\User */ - if ($account = user_load_by_name($role->id() . '.test')) { - if ($account->isBlocked()) { - $account->activate(); - $account->save(); + $account = user_load_by_name($username); + if (empty($account)) { + $account = User::create(); + $account->enforceIsNew(); + $account->setEmail('test+falcon-' . $role->id() . '@systemseed.com'); + $account->setUsername($role->id() . '.test'); + + if ($role->id() !== 'authenticated') { + $account->addRole($role->id()); } + + drupal_set_message(t('User @username was created.', ['@username' => $account->getUsername()])); + } + else { + $account->activate(); } + + $account->setPassword('password'); + $account->save(); } } + +/** + * Deactivate test users on non-development environments. + */ +function deactivateTestUsers() { + + /* @var $role \Drupal\user\Entity\Role */ + foreach (\Drupal\user\Entity\Role::loadMultiple() as $role) { + + /* @var $account \Drupal\user\Entity\User */ + $account = user_load_by_name($role->id() . '.test'); + if (!empty($account)) { + $account->block(); + $account->save(); + } + } +} + diff --git a/backend-donations/web/sites/default/default.settings.php b/backend-donations/web/sites/default/default.settings.php index 0e7caa3..ae8e504 100644 --- a/backend-donations/web/sites/default/default.settings.php +++ b/backend-donations/web/sites/default/default.settings.php @@ -88,7 +88,9 @@ * ); * @endcode */ -$databases = array(); +$databases = array( + +); /** * Customizing database settings. @@ -251,7 +253,9 @@ * ); * @endcode */ -$config_directories = array(); +$config_directories = array( + +); /** * Settings: @@ -278,6 +282,7 @@ * service requires the install profile use the 'install_profile' container * parameter. Functional code can use \Drupal::installProfile(). */ + # $settings['install_profile'] = ''; /** @@ -307,6 +312,7 @@ * custom code that changes the container, changing this identifier will also * allow the container to be invalidated as soon as code is deployed. */ + # $settings['deployment_identifier'] = \Drupal::VERSION; /** @@ -338,8 +344,11 @@ * You can also define an array of host names that can be accessed directly, * bypassing the proxy, in $settings['http_client_config']['proxy']['no']. */ + # $settings['http_client_config']['proxy']['http'] = 'http://proxy_user:proxy_pass@example.com:8080'; + # $settings['http_client_config']['proxy']['https'] = 'http://proxy_user:proxy_pass@example.com:8080'; + # $settings['http_client_config']['proxy']['no'] = ['127.0.0.1', 'localhost']; /** @@ -373,42 +382,49 @@ * Be aware, however, that it is likely that this would allow IP * address spoofing unless more advanced precautions are taken. */ + # $settings['reverse_proxy'] = TRUE; /** * Specify every reverse proxy IP address in your environment. * This setting is required if $settings['reverse_proxy'] is TRUE. */ + # $settings['reverse_proxy_addresses'] = array('a.b.c.d', ...); /** * Set this value if your proxy server sends the client IP in a header * other than X-Forwarded-For. */ + # $settings['reverse_proxy_header'] = 'X_CLUSTER_CLIENT_IP'; /** * Set this value if your proxy server sends the client protocol in a header * other than X-Forwarded-Proto. */ + # $settings['reverse_proxy_proto_header'] = 'X_FORWARDED_PROTO'; /** * Set this value if your proxy server sends the client protocol in a header * other than X-Forwarded-Host. */ + # $settings['reverse_proxy_host_header'] = 'X_FORWARDED_HOST'; /** * Set this value if your proxy server sends the client protocol in a header * other than X-Forwarded-Port. */ + # $settings['reverse_proxy_port_header'] = 'X_FORWARDED_PORT'; /** * Set this value if your proxy server sends the client protocol in a header * other than Forwarded. */ + # $settings['reverse_proxy_forwarded_header'] = 'FORWARDED'; /** @@ -427,8 +443,8 @@ * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid * getting cached pages from the proxy. */ -# $settings['omit_vary_cookie'] = TRUE; +# $settings['omit_vary_cookie'] = TRUE; /** * Cache TTL for client error (4xx) responses. @@ -440,6 +456,7 @@ * of client error responses set the value to 0. Currently applies only to * page_cache module. */ + # $settings['cache_ttl_4xx'] = 3600; /** @@ -450,6 +467,7 @@ * * @see \Drupal\Core\Form\FormCache::setCache() */ + # $settings['form_cache_expiration'] = 21600; /** @@ -459,6 +477,7 @@ * performance reasons. Detection can be prevented by setting * class_loader_auto_detect to false, as in the example below. */ + # $settings['class_loader_auto_detect'] = FALSE; /* @@ -473,6 +492,7 @@ * example, to use Symfony's APC class loader without automatic detection, * uncomment the code below. */ + /* if ($settings['hash_salt']) { $prefix = 'drupal.' . hash('sha256', 'drupal.' . $settings['hash_salt']); @@ -506,6 +526,7 @@ * * Remove the leading hash signs to disable. */ + # $settings['allow_authorize_operations'] = FALSE; /** @@ -513,7 +534,9 @@ * * Value should be in PHP Octal Notation, with leading zero. */ + # $settings['file_chmod_directory'] = 0775; + # $settings['file_chmod_file'] = 0664; /** @@ -527,6 +550,7 @@ * security by serving user-uploaded files from a different domain or subdomain * pointing to the same server. Do not include a trailing slash. */ + # $settings['file_public_base_url'] = 'http://downloads.example.com/files'; /** @@ -536,6 +560,7 @@ * must exist and be writable by Drupal. This directory must be relative to * the Drupal installation directory and be accessible over the web. */ + # $settings['file_public_path'] = 'sites/default/files'; /** @@ -551,6 +576,7 @@ * See https://www.drupal.org/documentation/modules/file for more information * about securing private files. */ + # $settings['file_private_path'] = ''; /** @@ -559,6 +585,7 @@ * Set the minimum interval between each session write to database. * For performance reasons it defaults to 180. */ + # $settings['session_write_interval'] = 180; /** @@ -573,9 +600,13 @@ * The "en" part of the variable name, is dynamic and can be any langcode of * any added language. (eg locale_custom_strings_de for german). */ + # $settings['locale_custom_strings_en'][''] = array( + # 'forum' => 'Discussion board', + # '@count min' => '@count minutes', + # ); /** @@ -588,6 +619,7 @@ * * Note: This setting does not apply to installation and update pages. */ + # $settings['maintenance_theme'] = 'bartik'; /** @@ -610,7 +642,9 @@ * and increase the limits of these variables. For more information, see * http://php.net/manual/pcre.configuration.php. */ + # ini_set('pcre.backtrack_limit', 200000); + # ini_set('pcre.recursion_limit', 200000); /** @@ -630,6 +664,7 @@ * override in a services.yml file in the same directory as settings.php * (definitions in this file will override service definition defaults). */ + # $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage'); /** @@ -654,9 +689,13 @@ * configuration values in settings.php will not fire any of the configuration * change events. */ + # $config['system.file']['path']['temporary'] = '/tmp'; + # $config['system.site']['name'] = 'My Drupal site'; + # $config['system.theme']['default'] = 'stark'; + # $config['user.settings']['anonymous'] = 'Visitor'; /** @@ -682,8 +721,11 @@ * * Remove the leading hash signs if you would like to alter this functionality. */ + # $config['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)|(?:system\/files)\//'; + # $config['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; + # $config['system.performance']['fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; /** @@ -698,6 +740,7 @@ * tracking purposes, for testing a service container with an error condition or * to test a service container that throws an exception. */ + # $settings['container_base_class'] = '\Drupal\Core\DependencyInjection\Container'; /** @@ -707,6 +750,7 @@ * alternate implementation YAML parser. The class must implement the * \Drupal\Component\Serialization\SerializationInterface interface. */ + # $settings['yaml_parser_class'] = NULL; /** @@ -781,7 +825,11 @@ * * Keep this code block at the end of this file to take full effect. */ + # + # if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) { + # include $app_root . '/' . $site_path . '/settings.local.php'; -# } + +# } \ No newline at end of file diff --git a/backend-donations/web/sites/default/settings.local.php b/backend-donations/web/sites/default/settings.local.php index 0d04a05..d5d21cb 100644 --- a/backend-donations/web/sites/default/settings.local.php +++ b/backend-donations/web/sites/default/settings.local.php @@ -7,23 +7,29 @@ assert_options(ASSERT_ACTIVE, TRUE); \Drupal\Component\Assertion\Handle::register(); +# Display all errors. +$config['system.logging']['error_level'] = 'verbose'; + // Set private files folder. $settings['file_private_path'] = preg_replace('~/web$~', '/private', $app_root); // Enable local development services. $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'; -$settings['hash_salt'] = 'Qf7s6_7c-W3lpFljM8ZSfYuUbAH6Ha5ldqFpJ177TzGggpOzVk9DI0OIsy80T58WU9uGkfsRCA'; - // Configure base url for images going outside of the site. $config['rest_absolute_urls']['base_url'] = 'http://donations.api.flc.local'; $settings['file_public_base_url'] = 'http://donations.api.flc.local/sites/default/files'; -$databases['default']['default'] = array( - 'driver' => 'mysql', - 'host' => 'be_donations_mariadb', +// Make default hash salt for local envs. +$settings['hash_salt'] = 'insecure-local-hash'; + +$databases['default']['default'] = array ( + 'database' => 'drupal', 'username' => 'drupal', 'password' => 'drupal', - 'database' => 'drupal', 'prefix' => '', + 'host' => 'be_donations_mariadb', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', ); diff --git a/backend-donations/web/sites/services.yml b/backend-donations/web/sites/services.yml index 23f6483..e1bbbc7 100644 --- a/backend-donations/web/sites/services.yml +++ b/backend-donations/web/sites/services.yml @@ -153,3 +153,22 @@ parameters: - sftp - webcal - rtsp + + # Configure Cross-Site HTTP requests (CORS). + # Read https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS + # for more information about the topic in general. + # Note: By default the configuration is disabled. + cors.config: + enabled: false + # Specify allowed headers, like 'x-allowed-header'. + allowedHeaders: [] + # Specify allowed request methods, specify ['*'] to allow all possible ones. + allowedMethods: [] + # Configure requests allowed from specific origins. + allowedOrigins: ['*'] + # Sets the Access-Control-Expose-Headers header. + exposedHeaders: false + # Sets the Access-Control-Max-Age header. + maxAge: false + # Sets the Access-Control-Allow-Credentials header. + supportsCredentials: false diff --git a/backend-gifts/web/modules/falcon/falcon_demo_content/content/user/9fca84d4-3c5c-44e9-9b38-0191f0d88969.json b/backend-gifts/web/modules/falcon/falcon_demo_content/content/user/9fca84d4-3c5c-44e9-9b38-0191f0d88969.json deleted file mode 100644 index fb4db51..0000000 --- a/backend-gifts/web/modules/falcon/falcon_demo_content/content/user/9fca84d4-3c5c-44e9-9b38-0191f0d88969.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "_links": { - "self": { - "href": "http:\/\/default\/user\/6?_format=hal_json" - }, - "type": { - "href": "http:\/\/drupal.org\/rest\/type\/user\/user" - } - }, - "uid": [ - { - "value": 6 - } - ], - "uuid": [ - { - "value": "9fca84d4-3c5c-44e9-9b38-0191f0d88969" - } - ], - "langcode": [ - { - "value": "en", - "lang": "en" - } - ], - "preferred_langcode": [ - { - "value": "en" - } - ], - "preferred_admin_langcode": [ - { - "value": "en" - } - ], - "name": [ - { - "value": "gifts_manager.test" - } - ], - "mail": [ - { - "value": "flc.gifts_manager-test@systemseed.com" - } - ], - "timezone": [ - { - "value": "UTC" - } - ], - "status": [ - { - "value": false - } - ], - "created": [ - { - "value": 1493111868 - } - ], - "changed": [ - { - "value": 1499073282, - "lang": "en" - } - ], - "access": [ - { - "value": 1496327425 - } - ], - "login": [ - { - "value": 1496327425 - } - ], - "init": [ - { - "value": "flc.gifts_manager-test@systemseed.com" - } - ], - "roles": [ - { - "target_id": "gifts_manager" - } - ], - "default_langcode": [ - { - "value": true, - "lang": "en" - } - ] -} \ No newline at end of file diff --git a/backend-gifts/web/modules/falcon/falcon_demo_content/content/user/dbb568e9-32f7-4a7b-a65b-bb6f636d8963.json b/backend-gifts/web/modules/falcon/falcon_demo_content/content/user/dbb568e9-32f7-4a7b-a65b-bb6f636d8963.json deleted file mode 100644 index 75269b9..0000000 --- a/backend-gifts/web/modules/falcon/falcon_demo_content/content/user/dbb568e9-32f7-4a7b-a65b-bb6f636d8963.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "_links": { - "self": { - "href": "http:\/\/default\/user\/2?_format=hal_json" - }, - "type": { - "href": "http:\/\/drupal.org\/rest\/type\/user\/user" - } - }, - "uid": [ - { - "value": 2 - } - ], - "uuid": [ - { - "value": "dbb568e9-32f7-4a7b-a65b-bb6f636d8963" - } - ], - "langcode": [ - { - "value": "en", - "lang": "en" - } - ], - "preferred_langcode": [ - { - "value": "en" - } - ], - "name": [ - { - "value": "administrator.test" - } - ], - "mail": [ - { - "value": "flc.administrator-test@systemseed.com" - } - ], - "timezone": [ - { - "value": "UTC" - } - ], - "status": [ - { - "value": true - } - ], - "created": [ - { - "value": 1488381426 - } - ], - "changed": [ - { - "value": 1509381336, - "lang": "en" - } - ], - "access": [ - { - "value": 1495130903 - } - ], - "login": [ - { - "value": 1495127436 - } - ], - "roles": [ - { - "target_id": "administrator" - } - ], - "default_langcode": [ - { - "value": true, - "lang": "en" - } - ] -} \ No newline at end of file diff --git a/backend-gifts/web/modules/falcon/falcon_development/falcon_development.install b/backend-gifts/web/modules/falcon/falcon_development/falcon_development.install index 786e18d..b8e210c 100644 --- a/backend-gifts/web/modules/falcon/falcon_development/falcon_development.install +++ b/backend-gifts/web/modules/falcon/falcon_development/falcon_development.install @@ -1,26 +1,72 @@ id() == 'anonymous') { + continue; + } + + $username = $role->id() . '.test'; + /* @var $account \Drupal\user\Entity\User */ - if ($account = user_load_by_name($role->id() . '.test')) { - if ($account->isBlocked()) { - $account->activate(); - $account->save(); + $account = user_load_by_name($username); + if (empty($account)) { + $account = User::create(); + $account->enforceIsNew(); + $account->setEmail('test+falcon-' . $role->id() . '@systemseed.com'); + $account->setUsername($role->id() . '.test'); + + if ($role->id() !== 'authenticated') { + $account->addRole($role->id()); } + + drupal_set_message(t('User @username was created.', ['@username' => $account->getUsername()])); + } + else { + $account->activate(); } + + $account->setPassword('password'); + $account->save(); } } + +/** + * Deactivate test users on non-development environments. + */ +function deactivateTestUsers() { + + /* @var $role \Drupal\user\Entity\Role */ + foreach (\Drupal\user\Entity\Role::loadMultiple() as $role) { + + /* @var $account \Drupal\user\Entity\User */ + $account = user_load_by_name($role->id() . '.test'); + if (!empty($account)) { + $account->block(); + $account->save(); + } + } +} + diff --git a/backend-gifts/web/sites/default/settings.local.php b/backend-gifts/web/sites/default/settings.local.php index 33e7167..73b88ab 100644 --- a/backend-gifts/web/sites/default/settings.local.php +++ b/backend-gifts/web/sites/default/settings.local.php @@ -7,8 +7,8 @@ assert_options(ASSERT_ACTIVE, TRUE); \Drupal\Component\Assertion\Handle::register(); -// Local hash salt. -$settings['hash_salt'] = 'ZRD02mi6oDCGcdd1UwtOinURHCS73x-E8wcRP1VFMSEJujEvl4grBelw4rPkMlrWe6QwqCbGaA'; +# Display all errors. +$config['system.logging']['error_level'] = 'verbose'; // Enable local development services. $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'; @@ -32,12 +32,16 @@ $config['routes']['backend-donations']['client_id'] = ''; $config['routes']['backend-donations']['client_secret'] = ''; -// Add your database configuration here. -$databases['default']['default'] = array( - 'driver' => 'mysql', - 'host' => 'be_gifts_mariadb', +// Make default hash salt for local envs. +$settings['hash_salt'] = 'insecure-local-hash'; + +$databases['default']['default'] = array ( + 'database' => 'drupal', 'username' => 'drupal', 'password' => 'drupal', - 'database' => 'drupal', 'prefix' => '', + 'host' => 'be_gifts_mariadb', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', ); diff --git a/docker-compose-mac.yml b/docker-compose-mac.yml deleted file mode 100644 index f2a7d5c..0000000 --- a/docker-compose-mac.yml +++ /dev/null @@ -1,177 +0,0 @@ -########################## -# Integration with docker-sync project for performance improvements on macOS. -# -# Installation: -# http://docs.docker4drupal.org/en/latest/macos/ -# -# Run: -# docker-sync start -d -# docker-compose -f ./docker-compose-mac.yml up -d -########################## - -version: '2' -services: - - ########################## - ### GIFTS FRONTEND ####### - ########################## - - fe_gifts: - image: node:6.9-alpine - environment: - VIRTUAL_HOST: gifts.flc.local - ports: - - "3000:3000" - volumes: - - ./frontend-gifts:/app - working_dir: /app - command: ['npm', 'start'] - - ########################## - ####### API BUS ########## - ########################## - - api_bus: - image: webdevops/php-nginx:alpine-3-php7 - environment: - WEB_ALIAS_DOMAIN: api.flc.local - WEB_DOCUMENT_ROOT: /app/public - VIRTUAL_HOST: api.flc.local - volumes: - - ./backend-api-bus:/app - working_dir: /app - - ########################## - ### GIFTS BACKEND ######## - ########################## - - be_gifts: - image: wodby/drupal-php:7.1 - environment: - PHP_SITE_NAME: dev - PHP_HOST_NAME: localhost - PHP_DOCROOT: web - PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 - # PHP_XDEBUG_ENABLED: 1 - # PHP_XDEBUG_AUTOSTART: 1 - # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow - # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' - volumes: -# - ./backend-gifts:/var/www/html - - d4d-unison-sync-gifts:/var/www/html:rw # Replace volume to this to use docker-sync for macOS users - - be_gifts_mariadb: - image: wodby/mariadb:10.1 - environment: - MYSQL_ROOT_PASSWORD: drupal - MYSQL_DATABASE: drupal - MYSQL_USER: drupal - MYSQL_PASSWORD: drupal - volumes: - - ./backend-gifts/sql-dump:/docker-entrypoint-initdb.d # Place init .sql file(s) here. - - be_gifts_nginx: - image: wodby/drupal-nginx:1.10-1.1.0 - environment: - NGINX_SERVER_NAME: localhost - NGINX_UPSTREAM_NAME: be_gifts - NGINX_DOCROOT: web - DRUPAL_VERSION: 8 - VIRTUAL_HOST: gifts.api.flc.local - volumes_from: - - be_gifts - - be_gifts_pma: - image: phpmyadmin/phpmyadmin - environment: - PMA_HOST: be_gifts_mariadb - PMA_USER: drupal - PMA_PASSWORD: drupal - PHP_UPLOAD_MAX_FILESIZE: 1G - PHP_MAX_INPUT_VARS: 1G - ports: - - "8001:80" - - - ########################## - ### DONATIONS BACKEND #### - ########################## - - be_donations: - image: wodby/drupal-php:7.1 - environment: - PHP_SITE_NAME: dev - PHP_HOST_NAME: localhost - PHP_DOCROOT: web - PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 - # PHP_XDEBUG_ENABLED: 1 - # PHP_XDEBUG_AUTOSTART: 1 - # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow - # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' - volumes: -# - ./backend-donations:/var/www/html - - d4d-unison-sync-donations:/var/www/html:rw # Replace volume to this to use docker-sync for macOS users - - be_donations_mariadb: - image: wodby/mariadb:10.1 - environment: - MYSQL_ROOT_PASSWORD: drupal - MYSQL_DATABASE: drupal - MYSQL_USER: drupal - MYSQL_PASSWORD: drupal - volumes: - - ./backend-donations/sql-dump:/docker-entrypoint-initdb.d # Place init .sql file(s) here. - - be_donations_nginx: - image: wodby/drupal-nginx:1.10-1.1.0 - environment: - NGINX_SERVER_NAME: localhost - NGINX_UPSTREAM_NAME: be_donations - NGINX_DOCROOT: web - DRUPAL_VERSION: 8 - VIRTUAL_HOST: donations.api.flc.local - volumes_from: - - be_donations - - be_donations_pma: - image: phpmyadmin/phpmyadmin - environment: - PMA_HOST: be_donations_mariadb - PMA_USER: drupal - PMA_PASSWORD: drupal - PHP_UPLOAD_MAX_FILESIZE: 1G - PHP_MAX_INPUT_VARS: 1G - ports: - - "8002:80" - - - ########################## - ### PHANTOM JS ########## - ########################## - - phantomjs: - image: rosenhouse/phantomjs2:latest - ports: - - 8910 - entrypoint: phantomjs - command: "--webdriver=8910" - - - ########################## - ### NGINX PROXY ########## - ########################## - - flc_nginx_proxy: - image: jwilder/nginx-proxy:0.5.0 - container_name: flc-nginx-proxy - ports: - - "80:80" - volumes: - - /var/run/docker.sock:/tmp/docker.sock:ro - -# Docker-sync for macOS users -volumes: - d4d-unison-sync-donations: - external: true - d4d-unison-sync-gifts: - external: true \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml deleted file mode 100644 index f6ca598..0000000 --- a/docker-compose.override.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: '3' - -services: - - fe_main: - volumes: - - ./frontend-main:/app - #- ./frontend-main:/app:cached - labels: - - 'traefik.frontend.rule=Host:main.flc.local' - - fe_gifts: - volumes: - - ./frontend-gifts:/app - #- ./frontend-gifts:/app:cached - # Uncomment to make changes in package.json. - #command: sh -c 'yarn install' - labels: - - 'traefik.frontend.rule=Host:gifts.flc.local' - - - # Uncomment to run app with Server Side Rendering enabled. - # Useful for debugging issues related to SSR. -# fe_gifts: -# command: sh -c 'yarn install && yarn run build && yarn run start:server' -# volumes: -# #- ./frontend-gifts:/app -# - ./frontend-gifts:/app:cached -# labels: -# - 'traefik.port=3001' -# - 'traefik.frontend.rule=Host:gifts.flc.local' - - api_bus: - image: webdevops/php-nginx:alpine-3-php7 - environment: - WEB_ALIAS_DOMAIN: api.flc.local - volumes: - - ./backend-api-bus:/app - #- ./backend-api-bus:/app:cached - labels: - - 'traefik.frontend.rule=Host:api.flc.local' - - be_gifts: - #environment: - # PHP_XDEBUG: 1 - # PHP_XDEBUG_DEFAULT_ENABLE: 1 - # PHP_XDEBUG_REMOTE_AUTOSTART: 1 - # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow - # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' - volumes: - - ./backend-gifts:/var/www/html - #- ./backend-gifts:/var/www/html:cached - - be_gifts_mariadb: - volumes: - - ./backend-gifts/mysql/data:/var/lib/mysql - #- ./backend-gifts/mysql/data:/var/lib/mysql:cached - - be_gifts_nginx: - volumes: - - ./backend-gifts:/var/www/html - #- ./backend-gifts:/var/www/html:cached - labels: - - 'traefik.frontend.rule=Host:gifts.api.flc.local' - - be_gifts_pma: - labels: - - 'traefik.frontend.rule=Host:pma.gifts.api.flc.local' - - be_donations: - #environment: - # PHP_XDEBUG: 1 - # PHP_XDEBUG_DEFAULT_ENABLE: 1 - # PHP_XDEBUG_REMOTE_AUTOSTART: 1 - # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow - # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' - volumes: - - ./backend-donations:/var/www/html - #- ./backend-donations:/var/www/html:cached - - be_donations_mariadb: - volumes: - - ./backend-donations/mysql/data:/var/lib/mysql - #- ./backend-donations/mysql/data:/var/lib/mysql:cached - - be_donations_nginx: - volumes: - - ./backend-donations:/var/www/html - #- ./backend-donations:/var/www/html:cached - labels: - - 'traefik.frontend.rule=Host:donations.api.flc.local' - - be_donations_pma: - labels: - - 'traefik.frontend.rule=Host:pma.donations.api.flc.local' diff --git a/docker-sync.yml b/docker-sync.yml deleted file mode 100644 index 7b7c6c5..0000000 --- a/docker-sync.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: "2" - -syncs: - d4d-unison-sync-donations: - src: './backend-donations' - dest: '/var/www/html' - sync_args: '-prefer newer' - sync_userid: '82' - sync_host_port: '10871' - sync_strategy: 'unison' - sync_excludes: ['.gitignore', '.git/', '.idea/'] - d4d-unison-sync-gifts: - src: './backend-gifts' - dest: '/var/www/html' - sync_args: '-prefer newer' - sync_userid: '82' - sync_host_port: '10871' - sync_strategy: 'unison' - sync_excludes: ['.gitignore', '.git/', '.idea/'] diff --git a/docker/docker-compose.override.default.yml b/docker/docker-compose.override.default.yml new file mode 100644 index 0000000..fa60fe8 --- /dev/null +++ b/docker/docker-compose.override.default.yml @@ -0,0 +1,103 @@ +version: '2' + +services: + + fe_main: + volumes: + - ../frontend-main:/app + #- ../frontend-main:/app:cached + labels: + - 'traefik.frontend.rule=Host:main.${PROJECT_BASE_URL}' + + fe_gifts: + volumes: + - ../frontend-gifts:/app + #- ../frontend-gifts:/app:cached + # Uncomment to make changes in package.json. + #command: sh -c 'yarn install' + labels: + - 'traefik.frontend.rule=Host:gifts.${PROJECT_BASE_URL}' + + # Uncomment to run app with Server Side Rendering enabled. + # Useful for debugging issues related to SSR. +# fe_gifts: +# command: sh -c 'yarn install && yarn run build && yarn run start:server' +# volumes: +# #- ../frontend-gifts:/app +# - ../frontend-gifts:/app:cached +# labels: +# - 'traefik.port=3001' +# - 'traefik.frontend.rule=Host:gifts.${PROJECT_BASE_URL}' + + api_bus: + image: webdevops/php-nginx:alpine-3-php7 + environment: + WEB_ALIAS_DOMAIN: api.${PROJECT_BASE_URL} + volumes: + - ../backend-api-bus:/app + #- ../backend-api-bus:/app:cached + labels: + - 'traefik.frontend.rule=Host:api.${PROJECT_BASE_URL}' + + be_gifts: + environment: + ## Read instructions at https://wodby.com/stacks/drupal/docs/local/xdebug/ + PHP_XDEBUG: 1 + PHP_XDEBUG_DEFAULT_ENABLE: 1 + # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 + # PHP_IDE_CONFIG: serverName=phpstorm + PHP_XDEBUG_REMOTE_HOST: 172.17.0.1 # Linux + # PHP_XDEBUG_REMOTE_HOST: 10.254.254.254 # macOS + # PHP_XDEBUG_REMOTE_HOST: 10.0.75.1 # Windows + volumes: + - ../backend-gifts:/var/www/html + #- ../backend-gifts:/var/www/html:cached + + be_gifts_mariadb: + volumes: + - ../backend-gifts/mysql/data:/var/lib/mysql + #- ../backend-gifts/mysql/data:/var/lib/mysql:cached + + be_gifts_nginx: + volumes: + - ../backend-gifts:/var/www/html + #- ../backend-gifts:/var/www/html:cached + labels: + - 'traefik.frontend.rule=Host:gifts.api.${PROJECT_BASE_URL}' + + be_gifts_pma: + labels: + - 'traefik.frontend.rule=Host:pma.gifts.api.${PROJECT_BASE_URL}' + + be_donations: + #environment: + # PHP_XDEBUG: 1 + # PHP_XDEBUG_DEFAULT_ENABLE: 1 + # PHP_XDEBUG_REMOTE_AUTOSTART: 1 + # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow + # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' + volumes: + - ../backend-donations:/var/www/html + #- ../backend-donations:/var/www/html:cached + + be_donations_mariadb: + volumes: + - ../backend-donations/mysql/data:/var/lib/mysql + #- ../backend-donations/mysql/data:/var/lib/mysql:cached + + be_donations_nginx: + volumes: + - ../backend-donations:/var/www/html + #- ../backend-donations:/var/www/html:cached + labels: + - 'traefik.frontend.rule=Host:donations.api.${PROJECT_BASE_URL}' + + be_donations_pma: + labels: + - 'traefik.frontend.rule=Host:pma.donations.api.${PROJECT_BASE_URL}' + + mailhog: + labels: + - 'traefik.backend=mailhog' + - 'traefik.port=8025' + - 'traefik.frontend.rule=Host:mailhog.${PROJECT_BASE_URL}' diff --git a/docker-compose.yml b/docker/docker-compose.yml similarity index 73% rename from docker-compose.yml rename to docker/docker-compose.yml index 7cb289a..bcf170e 100644 --- a/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,8 +1,8 @@ -version: '3' +version: '2' services: ########################## - ### MAIN FRONTEND ####### + ### MAIN FRONTEND ######## ########################## fe_main: @@ -52,15 +52,18 @@ services: ########################## be_gifts: - image: wodby/drupal-php:7.1-2.0.0 + image: wodby/drupal-php:7.1-dev-4.2.3 environment: - PHP_SITE_NAME: dev - PHP_HOST_NAME: localhost - PHP_DOCROOT: web PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 + DB_HOST: drupal + DB_USER: drupal + DB_PASSWORD: drupal + DB_NAME: drupal + DB_DRIVER: mysql be_gifts_mariadb: - image: wodby/mariadb:10.1 + image: wodby/mariadb:10.2-3.1.3 + stop_grace_period: 30s environment: MYSQL_ROOT_PASSWORD: drupal MYSQL_DATABASE: drupal @@ -68,15 +71,14 @@ services: MYSQL_PASSWORD: drupal be_gifts_nginx: - image: wodby/drupal-nginx:1.10-1.1.0 + image: wodby/drupal-nginx:8-1.13-4.0.3 depends_on: - be_gifts - - be_gifts_mariadb environment: - NGINX_SERVER_NAME: localhost - NGINX_UPSTREAM_NAME: be_gifts - NGINX_DOCROOT: web - DRUPAL_VERSION: 8 + NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off" + NGINX_ERROR_LOG_LEVEL: debug + NGINX_BACKEND_HOST: be_gifts + NGINX_SERVER_ROOT: /var/www/html/web labels: - 'traefik.backend=be_gifts_nginx' - 'traefik.port=80' @@ -99,15 +101,18 @@ services: ########################## be_donations: - image: wodby/drupal-php:7.1-2.2.0 + image: wodby/drupal-php:7.1-dev-4.2.3 environment: - PHP_SITE_NAME: dev - PHP_HOST_NAME: localhost - PHP_DOCROOT: web PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 + DB_HOST: drupal + DB_USER: drupal + DB_PASSWORD: drupal + DB_NAME: drupal + DB_DRIVER: mysql be_donations_mariadb: - image: wodby/mariadb:10.1 + image: wodby/mariadb:10.2-3.1.3 + stop_grace_period: 30s environment: MYSQL_ROOT_PASSWORD: drupal MYSQL_DATABASE: drupal @@ -115,15 +120,14 @@ services: MYSQL_PASSWORD: drupal be_donations_nginx: - image: wodby/drupal-nginx:1.10-1.1.0 + image: wodby/drupal-nginx:8-1.13-4.0.3 depends_on: - be_donations - - be_donations_mariadb environment: - NGINX_SERVER_NAME: localhost - NGINX_UPSTREAM_NAME: be_donations - NGINX_DOCROOT: web - DRUPAL_VERSION: 8 + NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off" + NGINX_ERROR_LOG_LEVEL: debug + NGINX_BACKEND_HOST: be_donations + NGINX_SERVER_ROOT: /var/www/html/web labels: - 'traefik.backend=be_donations_nginx' - 'traefik.port=80' @@ -137,7 +141,7 @@ services: PHP_UPLOAD_MAX_FILESIZE: 1G PHP_MAX_INPUT_VARS: 1G labels: - - 'traefik.backend=be_gifts_pma' + - 'traefik.backend=be_donations_pma' - 'traefik.port=80' ######################### @@ -146,9 +150,10 @@ services: mailhog: image: mailhog/mailhog - ports: - - "8025:8025" + ######################### + ###### TRAEFIK ########## + ######################### traefik: image: traefik From bb788972572acfc6c2acdd8e809bab5ac6de0701 Mon Sep 17 00:00:00 2001 From: spleshka Date: Wed, 4 Apr 2018 21:36:36 +0300 Subject: [PATCH 2/7] #6 Added support of tests. --- Makefile | 94 +- backend-gifts/tests/codeception/.gitignore | 3 + backend-gifts/tests/codeception/README.md | 65 - .../tests/codeception/codeception.yml | 54 +- .../tests/codeception/tests/_envs/chrome.yml | 9 +- .../tests/codeception/tests/_envs/firefox.yml | 6 - .../tests/_envs/phantom-circle.yml | 5 - .../tests/codeception/tests/_envs/phantom.yml | 7 - .../_generated/AcceptanceTesterActions.php | 2929 ----------------- .../_support/_generated/ApiTesterActions.php | 1451 -------- .../_generated/FunctionalTesterActions.php | 2274 ------------- .../_support/_generated/UnitTesterActions.php | 548 --- .../codeception/tests/acceptance.suite.yml | 29 +- .../tests/acceptance/falcon/user/UserCest.php | 19 - .../tests/codeception/tests/api.suite.yml | 10 +- .../codeception/tests/functional.suite.yml | 6 +- .../tests/codeception/tests/unit.suite.yml | 6 +- docker/docker-compose.yml | 20 + frontend-gifts/.gitignore | 5 +- frontend-gifts/server/index.js | 2 +- 20 files changed, 132 insertions(+), 7410 deletions(-) delete mode 100644 backend-gifts/tests/codeception/README.md delete mode 100644 backend-gifts/tests/codeception/tests/_envs/firefox.yml delete mode 100644 backend-gifts/tests/codeception/tests/_envs/phantom-circle.yml delete mode 100644 backend-gifts/tests/codeception/tests/_envs/phantom.yml delete mode 100644 backend-gifts/tests/codeception/tests/_support/_generated/AcceptanceTesterActions.php delete mode 100644 backend-gifts/tests/codeception/tests/_support/_generated/ApiTesterActions.php delete mode 100644 backend-gifts/tests/codeception/tests/_support/_generated/FunctionalTesterActions.php delete mode 100644 backend-gifts/tests/codeception/tests/_support/_generated/UnitTesterActions.php delete mode 100644 backend-gifts/tests/codeception/tests/acceptance/falcon/user/UserCest.php diff --git a/Makefile b/Makefile index 7439b05..8a1d2e4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: falcon falcon-install falcon-update drush +.PHONY: falcon falcon-install falcon-update drush test # Make sure the local file with docker-compose overrides exist. $(shell ! test -e \.\/docker\/docker-compose\.override\.yml && cat \.\/docker\/docker-compose\.override\.default\.yml > \.\/docker\/docker-compose\.override\.yml) @@ -9,51 +9,56 @@ $(shell ! test -e \.env && cat \.env.default > \.env) # Make all variables from the file available here. include .env -# Define two users for with different permissions within the php container. -php = docker-compose exec --user=82:82 $(firstword ${1}) sh -c "$(filter-out $(firstword ${1}), ${1})" -php-wodby = docker-compose exec $(firstword ${1}) sh -c "$(filter-out $(firstword ${1}), ${1})" - -falcon: - # Remove the first argument from the list of make commands. - $(eval COMMAND := $(filter-out $@,$(MAKECMDGOALS))) - @if [ "$(COMMAND)" = "install" ]; then\ - $(MAKE) -s falcon-install;\ - fi - @if [ "$(COMMAND)" = "update" ]; then\ - $(MAKE) -s falcon-update;\ - fi - @if [ "$(COMMAND)" != "update" ] && [ "$(COMMAND)" != "install" ]; then\ - echo "Command was not found. Try 'make falcon install' or 'make falcon update' instead." ;\ - fi +# Define two users for with different permissions within the container. +# docker-drupal is applicable only for php containers. +docker-drupal = docker-compose exec --user=82:82 $(firstword ${1}) sh -c "$(filter-out $(firstword ${1}), ${1})" +docker = docker-compose exec $(firstword ${1}) sh -c "$(filter-out $(firstword ${1}), ${1})" drush: - # Remove the first argument from the list of make commands. + # Remove the first argument from the list of make commands. $(eval ARGS := $(filter-out $@,$(MAKECMDGOALS))) @echo Target is \"$(firstword $(ARGS))\" @echo Executing \"drush -r /var/www/html/web $(filter-out $(firstword $(ARGS)), $(ARGS)) --yes\" - $(call php, $(filter $(firstword $(ARGS)), $(ARGS)) drush -r /var/www/html/web $(filter-out $(firstword $(ARGS)), $(ARGS)) --yes) + $(call docker-drupal, $(filter $(firstword $(ARGS)), $(ARGS)) drush -r /var/www/html/web $(filter-out $(firstword $(ARGS)), $(ARGS)) --yes) shell: - # Remove the first argument from the list of make commands. + # Remove the first argument from the list of make commands. $(eval ARGS := $(filter-out $@,$(MAKECMDGOALS))) @echo Target is \"$(firstword $(ARGS))\" @echo Executing \"shell $(filter-out $(firstword $(ARGS)), $(ARGS))\" - $(call php, $(filter $(firstword $(ARGS)), $(ARGS)) $(filter-out $(firstword $(ARGS)), $(ARGS))) - -down: - @docker-compose down --remove-orphans + $(call docker-drupal, $(filter $(firstword $(ARGS)), $(ARGS)) $(filter-out $(firstword $(ARGS)), $(ARGS))) + +tests\:prepare: + # Prepare codeception to run. + $(call docker, be_gifts ./vendor/bin/codecept --config=tests/codeception build) + # Run Gifts frontend with SSR support to test SSR as well. + @docker-compose stop fe_gifts + @docker-compose run fe_gifts yarn build + @docker-compose run -d fe_gifts yarn start:server + # Give node.js server several seconds to initialize. + @sleep 5 + +tests\:run: + $(MAKE) -s test be_gifts acceptance + +test: + # Remove the first argument from the list of make commands. + $(eval ARGS := $(filter-out $@,$(MAKECMDGOALS))) + @echo Target is \"$(firstword $(ARGS))\" + @echo Executing \"\./vendor/bin/codecept --config=tests/codeception run $(filter-out $(firstword $(ARGS)), $(ARGS))\" + $(call docker, $(firstword $(ARGS)) ./vendor/bin/codecept --config=tests/codeception run $(filter-out $(firstword $(ARGS)), $(ARGS)) --steps) -up: +env\:up: @docker-compose up -d --remove-orphans -####################################### -## Internal command. -## Invoked from "make falcon install". -## -## Builds the falcon from the buttom up. -####################################### +env\:down: + @docker-compose down --remove-orphans + +######################################### +## Builds the falcon from the buttom up # +######################################### -falcon-install: +falcon\:install: @echo "Installing Falcon from the bottom up..." @echo "Setting git config to ignore local files chmod..." @@ -90,7 +95,7 @@ falcon-install: @echo "#####################" @echo "Installing composer dependencies for API Bus..." - -$(call php-wodby, api_bus composer install) + -$(call docker, api_bus composer install) @echo "Copying default local config file for API bus into the adjustable local config..." @cp ./backend-api-bus/src/config/local.default.php ./backend-api-bus/src/config/local.php @@ -99,9 +104,7 @@ falcon-install: @echo "###########################" @echo "Installing composer dependencies for Gifts Backend..." - -$(call php-wodby, be_gifts composer install) - #@echo "Setting the right permissions for local settings.file..." - #-$(call php-wodby, be_gifts chmod 0777 web/sites/default/settings.php) + -$(call docker, be_gifts composer install) @echo "Installing Gifts site..." $(MAKE) -s drush be_gifts site-install config_installer @echo "Installing the module to import demo content..." @@ -114,9 +117,7 @@ falcon-install: @echo "###############################" @echo "Installing composer dependencies for Donations Backend..." - -$(call php-wodby, be_donations composer install) - #@echo "Setting the right permissions for local settings.file..." - #-$(call php-wodby, be_donations chmod 0777 web/sites/default/settings.php) + -$(call docker, be_donations composer install) @echo "Installing Donations site..." $(MAKE) -s drush be_donations site-install config_installer @echo "Installing the module to import demo content..." @@ -124,14 +125,11 @@ falcon-install: @echo "Disabling unnecessary modules after demo content import..." $(MAKE) -s drush be_donations pmu falcon_demo_content default_content better_normalizers hal -####################################### -## Internal command. -## Invoked from "make falcon update". -## -## Brings the falcon up to date with latest changes. -####################################### +###################################################### +## Brings the falcon up to date with latest changes ## +###################################################### -falcon-update: +falcon\:update: @echo "Updating the code from the git remote branch..." @git pull origin $(git rev-parse --abbrev-ref HEAD) @@ -142,7 +140,7 @@ falcon-update: docker-compose up -d --remove-orphans @echo "Updating composer dependencies for Donations backend..." - -$(call php-wodby, be_donations composer install) + -$(call docker, be_donations composer install) @echo "Updating cache on Donations backend..." $(MAKE) -s drush be_donations cr @echo "Applying database updates on Donations backend..." @@ -153,7 +151,7 @@ falcon-update: $(MAKE) -s drush be_donations entup @echo "Updating composer dependencies for Gifts backend..." - -$(call php-wodby, be_gifts composer install) + -$(call docker, be_gifts composer install) @echo "Updating cache on Gifts backend..." $(MAKE) -s drush be_gifts cr @echo "Applying database updates on Gifts backend..." diff --git a/backend-gifts/tests/codeception/.gitignore b/backend-gifts/tests/codeception/.gitignore index 9a620c1..82e6fce 100644 --- a/backend-gifts/tests/codeception/.gitignore +++ b/backend-gifts/tests/codeception/.gitignore @@ -1 +1,4 @@ tests/_output + +# Files generated for test suite. +tests/_support/_generated diff --git a/backend-gifts/tests/codeception/README.md b/backend-gifts/tests/codeception/README.md deleted file mode 100644 index ea5c234..0000000 --- a/backend-gifts/tests/codeception/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Codeception Test Suites - - -## Prepare for local run and development - -1. Make sure all URLs inside of `codeception.yml` file are valid. They should be valid if you're using Falcon Docker. - -2. From inside of Docker php container, build test helper CodeCeption files: - -``` -docker-compose run be_gifts sh -cd tests/codeception/ -../../vendor/bin/codecept build -``` - -## Run Unit Tests - -**Important:** currently, unit tests require Drupal database to be configured to fully bootstrap Drupal codebase. See `unit/_bootstrap.php` for details. - -Unit tests run on local codebase. No URL needs to be specified. - -Run the whole unit test suite: - -``` -../../vendor/bin/codecept run unit --debug -``` - -Run shared tests (both regions): - -``` -../../vendor/bin/codecept run unit shared/ --debug -``` - -Run specific Cest: - -``` -../../vendor/bin/codecept run unit shared/ExampleCest.php --debug -``` - -## Run Acceptance Tests - -Acceptance tests run on specified WebDriver URL. - -Run all acceptance tests in PhantomJS (debug mode): - -``` -../../vendor/bin/codecept run acceptance --env=phantom --debug -``` - -Run region specific tests: - -``` -../../vendor/bin/codecept run acceptance ie/ --env=phantom --debug -``` - - -## Run API Tests - -API tests run on specified REST URL. - -Run all API tests in debug mode: - -``` -../../vendor/bin/codecept run api --debug -``` diff --git a/backend-gifts/tests/codeception/codeception.yml b/backend-gifts/tests/codeception/codeception.yml index 150e38e..57a2a30 100644 --- a/backend-gifts/tests/codeception/codeception.yml +++ b/backend-gifts/tests/codeception/codeception.yml @@ -1,33 +1,33 @@ actor: Tester paths: - tests: tests - log: tests/_output - data: tests/_data - support: tests/_support - envs: tests/_envs + tests: tests + log: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs settings: - bootstrap: _bootstrap.php - colors: true - memory_limit: 1024M + bootstrap: _bootstrap.php + colors: true + memory_limit: 1024M extensions: - enabled: - - RunFailed - - CustomUrlsExtension - - PlatformExtension - #- Codeception\Extension\Recorder - config: - PlatformExtension: - http_user: falcon - http_pass: FALC0n$! + enabled: + - RunFailed + - CustomUrlsExtension + - PlatformExtension + #- Codeception\Extension\Recorder + config: + # TODO: Read from Circle's env. + PlatformExtension: + http_user: falcon + http_pass: FALC0n$! modules: - config: - WebDriver: - url: https://be_gifts_nginx - # TODO: place correct Docker URLs here. - frontend_url: https://fe_gifts - donations_url: https://be_donations_nginx - REST: - url: https://be_gifts_nginx - PhpBrowser: - url: https://be_gifts_nginx + config: + WebDriver: + url: http://gifts.api.flc.local + frontend_url: http://gifts.flc.local + donations_url: http://donations.api.flc.local + REST: + url: http://gifts.api.flc.local + PhpBrowser: + url: http://gifts.api.flc.local diff --git a/backend-gifts/tests/codeception/tests/_envs/chrome.yml b/backend-gifts/tests/codeception/tests/_envs/chrome.yml index 464bab1..f5c732a 100644 --- a/backend-gifts/tests/codeception/tests/_envs/chrome.yml +++ b/backend-gifts/tests/codeception/tests/_envs/chrome.yml @@ -1,6 +1,7 @@ -# `phantom` environment config goes here +# Configuration of chrome environment. modules: config: - WebDriver: - browser: 'chrome' - port: 9515 + WebDriver: + browser: chrome + host: chrome + port: 4444 diff --git a/backend-gifts/tests/codeception/tests/_envs/firefox.yml b/backend-gifts/tests/codeception/tests/_envs/firefox.yml deleted file mode 100644 index e4ae960..0000000 --- a/backend-gifts/tests/codeception/tests/_envs/firefox.yml +++ /dev/null @@ -1,6 +0,0 @@ -# `firefox` environment config goes here -modules: - config: - WebDriver: - browser: 'firefox' - port: 4444 diff --git a/backend-gifts/tests/codeception/tests/_envs/phantom-circle.yml b/backend-gifts/tests/codeception/tests/_envs/phantom-circle.yml deleted file mode 100644 index 992bc35..0000000 --- a/backend-gifts/tests/codeception/tests/_envs/phantom-circle.yml +++ /dev/null @@ -1,5 +0,0 @@ -# `phantom` environment for CircleCI. -modules: - config: - WebDriver: - browser: 'phantomjs' diff --git a/backend-gifts/tests/codeception/tests/_envs/phantom.yml b/backend-gifts/tests/codeception/tests/_envs/phantom.yml deleted file mode 100644 index 492d1de..0000000 --- a/backend-gifts/tests/codeception/tests/_envs/phantom.yml +++ /dev/null @@ -1,7 +0,0 @@ -# `phantom` environment config goes here -modules: - config: - WebDriver: - host: phantomjs - browser: 'phantomjs' - port: 8910 diff --git a/backend-gifts/tests/codeception/tests/_support/_generated/AcceptanceTesterActions.php b/backend-gifts/tests/codeception/tests/_support/_generated/AcceptanceTesterActions.php deleted file mode 100644 index 323f169..0000000 --- a/backend-gifts/tests/codeception/tests/_support/_generated/AcceptanceTesterActions.php +++ /dev/null @@ -1,2929 +0,0 @@ -getScenario()->runStep(new \Codeception\Step\Action('debugWebDriverLogs', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Changes the subdomain for the 'url' configuration parameter. - * Does not open a page; use `amOnPage` for that. - * - * ``` php - * amOnSubdomain('user'); - * $I->amOnPage('/'); - * // moves to http://user.mysite.com/ - * ?> - * ``` - * - * @param $subdomain - * - * @return mixed - * @see \Codeception\Module\WebDriver::amOnSubdomain() - */ - public function amOnSubdomain($subdomain) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Takes a screenshot of the current window and saves it to `tests/_output/debug`. - * - * ``` php - * amOnPage('/user/edit'); - * $I->makeScreenshot('edit_page'); - * // saved to: tests/_output/debug/edit_page.png - * $I->makeScreenshot(); - * // saved to: tests/_output/debug/2017-05-26_14-24-11_4b3403665fea6.png - * ``` - * - * @param $name - * @see \Codeception\Module\WebDriver::makeScreenshot() - */ - public function makeScreenshot($name = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('makeScreenshot', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Resize the current window. - * - * ``` php - * resizeWindow(800, 600); - * - * ``` - * - * @param int $width - * @param int $height - * @see \Codeception\Module\WebDriver::resizeWindow() - */ - public function resizeWindow($width, $height) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('resizeWindow', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` - * - * @param $cookie - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCookie() - */ - public function canSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` - * - * @param $cookie - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::seeCookie() - */ - public function seeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCookie() - */ - public function cantSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::dontSeeCookie() - */ - public function dontSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets a cookie with the given name and value. - * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. - * - * ``` php - * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); - * ?> - * ``` - * - * @param $name - * @param $val - * @param array $params - * - * @return mixed - * @see \Codeception\Module\WebDriver::setCookie() - */ - public function setCookie($cookie, $value, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unsets cookie with the given name. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::resetCookie() - */ - public function resetCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs a cookie value. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::grabCookie() - */ - public function grabCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs current page source code. - * - * @throws ModuleException if no page was opened. - * - * @return string Current page source code. - * @see \Codeception\Module\WebDriver::grabPageSource() - */ - public function grabPageSource() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabPageSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Open web page at the given absolute URL and sets its hostname as the base host. - * - * ``` php - * amOnUrl('http://codeception.com'); - * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart - * ?> - * ``` - * @see \Codeception\Module\WebDriver::amOnUrl() - */ - public function amOnUrl($url) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opens the page for the given relative URI. - * - * ``` php - * amOnPage('/'); - * // opens /register page - * $I->amOnPage('/register'); - * ``` - * - * @param string $page - * @see \Codeception\Module\WebDriver::amOnPage() - */ - public function amOnPage($page) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string (case insensitive). - * - * You can specify a specific HTML element (via CSS or XPath) as the second - * parameter to only search within that element. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page - * $I->see('Sign Up', '//body/h1'); // with XPath - * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->see('strong')` will return true for strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will *not* be true for strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param string $text - * @param string $selector optional - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::see() - */ - public function canSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string (case insensitive). - * - * You can specify a specific HTML element (via CSS or XPath) as the second - * parameter to only search within that element. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page - * $I->see('Sign Up', '//body/h1'); // with XPath - * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->see('strong')` will return true for strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will *not* be true for strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param string $text - * @param string $selector optional - * @see \Codeception\Module\WebDriver::see() - */ - public function see($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified (case insensitive). - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->dontSee('strong')` will fail on strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will ignore strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param string $text - * @param string $selector optional - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSee() - */ - public function cantSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified (case insensitive). - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->dontSee('strong')` will fail on strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will ignore strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param string $text - * @param string $selector optional - * @see \Codeception\Module\WebDriver::dontSee() - */ - public function dontSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ``` php - * seeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInSource() - */ - public function canSeeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ``` php - * seeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * @see \Codeception\Module\WebDriver::seeInSource() - */ - public function seeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ```php - * dontSeeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInSource() - */ - public function cantSeeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ```php - * dontSeeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * @see \Codeception\Module\WebDriver::dontSeeInSource() - */ - public function dontSeeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page source contains the given string. - * - * ```php - * seeInPageSource('getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPageSource', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page source contains the given string. - * - * ```php - * seeInPageSource('getScenario()->runStep(new \Codeception\Step\Assertion('seeInPageSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page source doesn't contain the given string. - * - * @param $text - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInPageSource() - */ - public function cantSeeInPageSource($text) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInPageSource', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page source doesn't contain the given string. - * - * @param $text - * @see \Codeception\Module\WebDriver::dontSeeInPageSource() - */ - public function dontSeeInPageSource($text) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInPageSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Perform a click on a link or a button, given by a locator. - * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. - * For buttons, the "value" attribute, "name" attribute, and inner text are searched. - * For links, the link text is searched. - * For images, the "alt" attribute and inner text of any parent links are searched. - * - * The second parameter is a context (CSS or XPath locator) to narrow the search. - * - * Note that if the locator matches a button of type `submit`, the form will be submitted. - * - * ``` php - * click('Logout'); - * // button of form - * $I->click('Submit'); - * // CSS button - * $I->click('#form input[type=submit]'); - * // XPath - * $I->click('//form/*[@type=submit]'); - * // link in context - * $I->click('Logout', '#nav'); - * // using strict locator - * $I->click(['link' => 'Login']); - * ?> - * ``` - * - * @param $link - * @param $context - * @see \Codeception\Module\WebDriver::click() - */ - public function click($link, $context = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param string $text - * @param string $url optional - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeLink() - */ - public function canSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param string $text - * @param string $url optional - * @see \Codeception\Module\WebDriver::seeLink() - */ - public function seeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param string $text - * @param string $url optional - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeLink() - */ - public function cantSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param string $text - * @param string $url optional - * @see \Codeception\Module\WebDriver::dontSeeLink() - */ - public function dontSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param string $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInCurrentUrl() - */ - public function canSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param string $uri - * @see \Codeception\Module\WebDriver::seeInCurrentUrl() - */ - public function seeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param string $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() - */ - public function canSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param string $uri - * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() - */ - public function seeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param string $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches() - */ - public function canSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param string $uri - * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches() - */ - public function seeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param string $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl() - */ - public function cantSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param string $uri - * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl() - */ - public function dontSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param string $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() - */ - public function cantSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param string $uri - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() - */ - public function dontSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url doesn't match the given regular expression. - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param string $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() - */ - public function cantSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url doesn't match the given regular expression. - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param string $uri - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() - */ - public function dontSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Executes the given regular expression against the current URI and returns the first capturing group. - * If no parameters are provided, the full URI is returned. - * - * ``` php - * grabFromCurrentUrl('~$/user/(\d+)/~'); - * $uri = $I->grabFromCurrentUrl(); - * ?> - * ``` - * - * @param string $uri optional - * - * @return mixed - * @see \Codeception\Module\WebDriver::grabFromCurrentUrl() - */ - public function grabFromCurrentUrl($uri = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the specified checkbox is checked. - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() - */ - public function canSeeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the specified checkbox is checked. - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() - */ - public function seeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check that the specified checkbox is unchecked. - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() - */ - public function cantSeeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check that the specified checkbox is unchecked. - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() - */ - public function dontSeeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value. - * Fields are matched by label text, the "name" attribute, CSS, or XPath. - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInField() - */ - public function canSeeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value. - * Fields are matched by label text, the "name" attribute, CSS, or XPath. - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Module\WebDriver::seeInField() - */ - public function seeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain the given value. - * For fuzzy locators, the field is matched by label text, CSS and XPath. - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->dontSeeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInField() - */ - public function cantSeeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain the given value. - * For fuzzy locators, the field is matched by label text, CSS and XPath. - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->dontSeeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Module\WebDriver::dontSeeInField() - */ - public function dontSeeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are set on the form matched with the - * passed selector. - * - * ``` php - * seeInFormFields('form[name=myform]', [ - * 'input1' => 'value', - * 'input2' => 'other value', - * ]); - * ?> - * ``` - * - * For multi-select elements, or to check values of multiple elements with the same name, an - * array may be passed: - * - * ``` php - * seeInFormFields('.form-class', [ - * 'multiselect' => [ - * 'value1', - * 'value2', - * ], - * 'checkbox[]' => [ - * 'a checked value', - * 'another checked value', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * seeInFormFields('#form-id', [ - * 'checkbox1' => true, // passes if checked - * 'checkbox2' => false, // passes if unchecked - * ]); - * ?> - * ``` - * - * Pair this with submitForm for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInFormFields() - */ - public function canSeeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are set on the form matched with the - * passed selector. - * - * ``` php - * seeInFormFields('form[name=myform]', [ - * 'input1' => 'value', - * 'input2' => 'other value', - * ]); - * ?> - * ``` - * - * For multi-select elements, or to check values of multiple elements with the same name, an - * array may be passed: - * - * ``` php - * seeInFormFields('.form-class', [ - * 'multiselect' => [ - * 'value1', - * 'value2', - * ], - * 'checkbox[]' => [ - * 'a checked value', - * 'another checked value', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * seeInFormFields('#form-id', [ - * 'checkbox1' => true, // passes if checked - * 'checkbox2' => false, // passes if unchecked - * ]); - * ?> - * ``` - * - * Pair this with submitForm for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * @see \Codeception\Module\WebDriver::seeInFormFields() - */ - public function seeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are not set on the form matched with - * the passed selector. - * - * ``` php - * dontSeeInFormFields('form[name=myform]', [ - * 'input1' => 'non-existent value', - * 'input2' => 'other non-existent value', - * ]); - * ?> - * ``` - * - * To check that an element hasn't been assigned any one of many values, an array can be passed - * as the value: - * - * ``` php - * dontSeeInFormFields('.form-class', [ - * 'fieldName' => [ - * 'This value shouldn\'t be set', - * 'And this value shouldn\'t be set', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * dontSeeInFormFields('#form-id', [ - * 'checkbox1' => true, // fails if checked - * 'checkbox2' => false, // fails if unchecked - * ]); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInFormFields() - */ - public function cantSeeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are not set on the form matched with - * the passed selector. - * - * ``` php - * dontSeeInFormFields('form[name=myform]', [ - * 'input1' => 'non-existent value', - * 'input2' => 'other non-existent value', - * ]); - * ?> - * ``` - * - * To check that an element hasn't been assigned any one of many values, an array can be passed - * as the value: - * - * ``` php - * dontSeeInFormFields('.form-class', [ - * 'fieldName' => [ - * 'This value shouldn\'t be set', - * 'And this value shouldn\'t be set', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * dontSeeInFormFields('#form-id', [ - * 'checkbox1' => true, // fails if checked - * 'checkbox2' => false, // fails if unchecked - * ]); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * @see \Codeception\Module\WebDriver::dontSeeInFormFields() - */ - public function dontSeeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Selects an option in a select tag or in radio button group. - * - * ``` php - * selectOption('form select[name=account]', 'Premium'); - * $I->selectOption('form input[name=payment]', 'Monthly'); - * $I->selectOption('//form/select[@name=account]', 'Monthly'); - * ?> - * ``` - * - * Provide an array for the second argument to select multiple options: - * - * ``` php - * selectOption('Which OS do you use?', array('Windows','Linux')); - * ?> - * ``` - * - * Or provide an associative array for the second argument to specifically define which selection method should be used: - * - * ``` php - * selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' - * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' - * ?> - * ``` - * - * @param $select - * @param $option - * @see \Codeception\Module\WebDriver::selectOption() - */ - public function selectOption($select, $option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unselect an option in the given select box. - * - * @param $select - * @param $option - * @see \Codeception\Module\WebDriver::unselectOption() - */ - public function unselectOption($select, $option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('unselectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. - * - * ``` php - * checkOption('#agree'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Module\WebDriver::checkOption() - */ - public function checkOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unticks a checkbox. - * - * ``` php - * uncheckOption('#notify'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Module\WebDriver::uncheckOption() - */ - public function uncheckOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fills a text field or textarea with the given string. - * - * ``` php - * fillField("//input[@type='text']", "Hello World!"); - * $I->fillField(['name' => 'email'], 'jon@mail.com'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Module\WebDriver::fillField() - */ - public function fillField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Attaches a file relative to the Codeception `_data` directory to the given file upload field. - * - * ``` php - * attachFile('input[@type="file"]', 'prices.xls'); - * ?> - * ``` - * - * @param $field - * @param $filename - * @see \Codeception\Module\WebDriver::attachFile() - */ - public function attachFile($field, $filename) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Finds and returns the text contents of the given element. - * If a fuzzy locator is used, the element is found using CSS, XPath, - * and by matching the full page source by regular expression. - * - * ``` php - * grabTextFrom('h1'); - * $heading = $I->grabTextFrom('descendant-or-self::h1'); - * $value = $I->grabTextFrom('~ - * ``` - * - * @param $cssOrXPathOrRegex - * - * @return mixed - * @see \Codeception\Module\WebDriver::grabTextFrom() - */ - public function grabTextFrom($cssOrXPathOrRegex) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs the value of the given attribute value from the given element. - * Fails if element is not found. - * - * ``` php - * grabAttributeFrom('#tooltip', 'title'); - * ?> - * ``` - * - * - * @param $cssOrXpath - * @param $attribute - * - * @return mixed - * @see \Codeception\Module\WebDriver::grabAttributeFrom() - */ - public function grabAttributeFrom($cssOrXpath, $attribute) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Finds the value for the given form field. - * If a fuzzy locator is used, the field is found by field name, CSS, and XPath. - * - * ``` php - * grabValueFrom('Name'); - * $name = $I->grabValueFrom('input[name=username]'); - * $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']'); - * $name = $I->grabValueFrom(['name' => 'username']); - * ?> - * ``` - * - * @param $field - * - * @return mixed - * @see \Codeception\Module\WebDriver::grabValueFrom() - */ - public function grabValueFrom($field) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs either the text content, or attribute values, of nodes - * matched by $cssOrXpath and returns them as an array. - * - * ```html - * First - * Second - * Third - * ``` - * - * ```php - * grabMultiple('a'); - * - * // would return ['#first', '#second', '#third'] - * $aLinks = $I->grabMultiple('a', 'href'); - * ?> - * ``` - * - * @param $cssOrXpath - * @param $attribute - * @return string[] - * @see \Codeception\Module\WebDriver::grabMultiple() - */ - public function grabMultiple($cssOrXpath, $attribute = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeElement() - */ - public function canSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * @see \Codeception\Module\WebDriver::seeElement() - */ - public function seeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeElement() - */ - public function cantSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @see \Codeception\Module\WebDriver::dontSeeElement() - */ - public function dontSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page, even it is invisible. - * - * ``` php - * seeElementInDOM('//form/input[type=hidden]'); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeElementInDOM() - */ - public function canSeeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElementInDOM', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page, even it is invisible. - * - * ``` php - * seeElementInDOM('//form/input[type=hidden]'); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @see \Codeception\Module\WebDriver::seeElementInDOM() - */ - public function seeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElementInDOM', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opposite of `seeElementInDOM`. - * - * @param $selector - * @param array $attributes - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeElementInDOM() - */ - public function cantSeeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElementInDOM', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opposite of `seeElementInDOM`. - * - * @param $selector - * @param array $attributes - * @see \Codeception\Module\WebDriver::dontSeeElementInDOM() - */ - public function dontSeeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElementInDOM', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); // between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected int or int[] - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeNumberOfElements() - */ - public function canSeeNumberOfElements($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); // between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected int or int[] - * @see \Codeception\Module\WebDriver::seeNumberOfElements() - */ - public function seeNumberOfElements($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM() - */ - public function canSeeNumberOfElementsInDOM($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElementsInDOM', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM() - */ - public function seeNumberOfElementsInDOM($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElementsInDOM', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeOptionIsSelected() - */ - public function canSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Module\WebDriver::seeOptionIsSelected() - */ - public function seeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected() - */ - public function cantSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected() - */ - public function dontSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title contains the given string. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInTitle() - */ - public function canSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title contains the given string. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * @see \Codeception\Module\WebDriver::seeInTitle() - */ - public function seeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInTitle() - */ - public function cantSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * @see \Codeception\Module\WebDriver::dontSeeInTitle() - */ - public function dontSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Accepts the active JavaScript native popup window, as created by `window.alert`|`window.confirm`|`window.prompt`. - * Don't confuse popups with modal windows, - * as created by [various libraries](http://jster.net/category/windows-modals-popups). - * @see \Codeception\Module\WebDriver::acceptPopup() - */ - public function acceptPopup() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('acceptPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Dismisses the active JavaScript popup, as created by `window.alert`, `window.confirm`, or `window.prompt`. - * @see \Codeception\Module\WebDriver::cancelPopup() - */ - public function cancelPopup() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('cancelPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the active JavaScript popup, - * as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. - * - * @param $text - * - * @throws \Codeception\Exception\ModuleException - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInPopup() - */ - public function canSeeInPopup($text) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPopup', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the active JavaScript popup, - * as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. - * - * @param $text - * - * @throws \Codeception\Exception\ModuleException - * @see \Codeception\Module\WebDriver::seeInPopup() - */ - public function seeInPopup($text) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Enters text into a native JavaScript prompt popup, as created by `window.prompt`. - * - * @param $keys - * - * @throws \Codeception\Exception\ModuleException - * @see \Codeception\Module\WebDriver::typeInPopup() - */ - public function typeInPopup($keys) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('typeInPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Reloads the current page. - * @see \Codeception\Module\WebDriver::reloadPage() - */ - public function reloadPage() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('reloadPage', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Moves back in history. - * @see \Codeception\Module\WebDriver::moveBack() - */ - public function moveBack() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('moveBack', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Moves forward in history. - * @see \Codeception\Module\WebDriver::moveForward() - */ - public function moveForward() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('moveForward', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Submits the given form on the page, optionally with the given form - * values. Give the form fields values as an array. Note that hidden fields - * can't be accessed. - * - * Skipped fields will be filled by their values from the page. - * You don't need to click the 'Submit' button afterwards. - * This command itself triggers the request to form's action. - * - * You can optionally specify what button's value to include - * in the request with the last parameter as an alternative to - * explicitly setting its value in the second parameter, as - * button values are not otherwise included in the request. - * - * Examples: - * - * ``` php - * submitForm('#login', [ - * 'login' => 'davert', - * 'password' => '123456' - * ]); - * // or - * $I->submitForm('#login', [ - * 'login' => 'davert', - * 'password' => '123456' - * ], 'submitButtonName'); - * - * ``` - * - * For example, given this sample "Sign Up" form: - * - * ``` html - *
- * Login: - *
- * Password: - *
- * Do you agree to our terms? - *
- * Select pricing plan: - * - * - *
- * ``` - * - * You could write the following to submit it: - * - * ``` php - * submitForm( - * '#userForm', - * [ - * 'user[login]' => 'Davert', - * 'user[password]' => '123456', - * 'user[agree]' => true - * ], - * 'submitButton' - * ); - * ``` - * Note that "2" will be the submitted value for the "plan" field, as it is - * the selected option. - * - * Also note that this differs from PhpBrowser, in that - * ```'user' => [ 'login' => 'Davert' ]``` is not supported at the moment. - * Named array keys *must* be included in the name as above. - * - * Pair this with seeInFormFields for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * Parameter values must be set to arrays for multiple input fields - * of the same name, or multi-select combo boxes. For checkboxes, - * either the string value can be used, or boolean values which will - * be replaced by the checkbox's value in the DOM. - * - * ``` php - * submitForm('#my-form', [ - * 'field1' => 'value', - * 'checkbox' => [ - * 'value of first checkbox', - * 'value of second checkbox, - * ], - * 'otherCheckboxes' => [ - * true, - * false, - * false - * ], - * 'multiselect' => [ - * 'first option value', - * 'second option value' - * ] - * ]); - * ?> - * ``` - * - * Mixing string and boolean values for a checkbox's value is not supported - * and may produce unexpected results. - * - * Field names ending in "[]" must be passed without the trailing square - * bracket characters, and must contain an array for its value. This allows - * submitting multiple values with the same name, consider: - * - * ```php - * $I->submitForm('#my-form', [ - * 'field[]' => 'value', - * 'field[]' => 'another value', // 'field[]' is already a defined key - * ]); - * ``` - * - * The solution is to pass an array value: - * - * ```php - * // this way both values are submitted - * $I->submitForm('#my-form', [ - * 'field' => [ - * 'value', - * 'another value', - * ] - * ]); - * ``` - * - * The `$button` parameter can be either a string, an array or an instance - * of Facebook\WebDriver\WebDriverBy. When it is a string, the - * button will be found by its "name" attribute. If $button is an - * array then it will be treated as a strict selector and a WebDriverBy - * will be used verbatim. - * - * For example, given the following HTML: - * - * ``` html - * - * ``` - * - * `$button` could be any one of the following: - * - 'submitButton' - * - ['name' => 'submitButton'] - * - WebDriverBy::name('submitButton') - * - * @param $selector - * @param $params - * @param $button - * @see \Codeception\Module\WebDriver::submitForm() - */ - public function submitForm($selector, $params, $button = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Waits up to $timeout seconds for the given element to change. - * Element "change" is determined by a callback function which is called repeatedly - * until the return value evaluates to true. - * - * ``` php - * waitForElementChange('#menu', function(WebDriverElement $el) { - * return $el->isDisplayed(); - * }, 100); - * ?> - * ``` - * - * @param $element - * @param \Closure $callback - * @param int $timeout seconds - * @throws \Codeception\Exception\ElementNotFound - * @see \Codeception\Module\WebDriver::waitForElementChange() - */ - public function waitForElementChange($element, $callback, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementChange', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Waits up to $timeout seconds for an element to appear on the page. - * If the element doesn't appear, a timeout exception is thrown. - * - * ``` php - * waitForElement('#agree_button', 30); // secs - * $I->click('#agree_button'); - * ?> - * ``` - * - * @param $element - * @param int $timeout seconds - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForElement() - */ - public function waitForElement($element, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Waits up to $timeout seconds for the given element to be visible on the page. - * If element doesn't appear, a timeout exception is thrown. - * - * ``` php - * waitForElementVisible('#agree_button', 30); // secs - * $I->click('#agree_button'); - * ?> - * ``` - * - * @param $element - * @param int $timeout seconds - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForElementVisible() - */ - public function waitForElementVisible($element, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementVisible', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Waits up to $timeout seconds for the given element to become invisible. - * If element stays visible, a timeout exception is thrown. - * - * ``` php - * waitForElementNotVisible('#agree_button', 30); // secs - * ?> - * ``` - * - * @param $element - * @param int $timeout seconds - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForElementNotVisible() - */ - public function waitForElementNotVisible($element, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementNotVisible', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Waits up to $timeout seconds for the given string to appear on the page. - * - * Can also be passed a selector to search in, be as specific as possible when using selectors. - * waitForText() will only watch the first instance of the matching selector / text provided. - * If the given text doesn't appear, a timeout exception is thrown. - * - * ``` php - * waitForText('foo', 30); // secs - * $I->waitForText('foo', 30, '.title'); // secs - * ?> - * ``` - * - * @param string $text - * @param int $timeout seconds - * @param string $selector optional - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForText() - */ - public function waitForText($text, $timeout = null, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForText', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Wait for $timeout seconds. - * - * @param int|float $timeout secs - * @throws \Codeception\Exception\TestRuntimeException - * @see \Codeception\Module\WebDriver::wait() - */ - public function wait($timeout) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('wait', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Low-level API method. - * If Codeception commands are not enough, this allows you to use Selenium WebDriver methods directly: - * - * ``` php - * $I->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) { - * $webdriver->get('http://google.com'); - * }); - * ``` - * - * This runs in the context of the - * [RemoteWebDriver class](https://github.com/facebook/php-webdriver/blob/master/lib/remote/RemoteWebDriver.php). - * Try not to use this command on a regular basis. - * If Codeception lacks a feature you need, please implement it and submit a patch. - * - * @param callable $function - * @see \Codeception\Module\WebDriver::executeInSelenium() - */ - public function executeInSelenium($function) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInSelenium', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Switch to another window identified by name. - * - * The window can only be identified by name. If the $name parameter is blank, the parent window will be used. - * - * Example: - * ``` html - * - * ``` - * - * ``` php - * click("Open window"); - * # switch to another window - * $I->switchToWindow("another_window"); - * # switch to parent window - * $I->switchToWindow(); - * ?> - * ``` - * - * If the window has no name, match it by switching to next active tab using `switchToNextTab` method. - * - * Or use native Selenium functions to get access to all opened windows: - * - * ``` php - * executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) { - * $handles=$webdriver->getWindowHandles(); - * $last_window = end($handles); - * $webdriver->switchTo()->window($last_window); - * }); - * ?> - * ``` - * - * @param string|null $name - * @see \Codeception\Module\WebDriver::switchToWindow() - */ - public function switchToWindow($name = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToWindow', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Switch to another frame on the page. - * - * Example: - * ``` html - *