{"id":17797391,"url":"https://github.com/steevanb/php-url-test","last_synced_at":"2025-03-17T04:31:17.281Z","repository":{"id":54312434,"uuid":"85125841","full_name":"steevanb/php-url-test","owner":"steevanb","description":"Tests all urls of your application","archived":false,"fork":false,"pushed_at":"2021-02-24T20:25:54.000Z","size":195,"stargazers_count":3,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-04T02:40:43.149Z","etag":null,"topics":["php","symfony-console"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steevanb.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-15T22:12:10.000Z","updated_at":"2024-05-04T02:40:43.149Z","dependencies_parsed_at":"2022-08-13T11:40:58.049Z","dependency_job_id":null,"html_url":"https://github.com/steevanb/php-url-test","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-url-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-url-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-url-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-url-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steevanb","download_url":"https://codeload.github.com/steevanb/php-url-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221671736,"owners_count":16861299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","symfony-console"],"created_at":"2024-10-27T11:55:37.561Z","updated_at":"2024-10-27T11:55:38.060Z","avatar_url":"https://github.com/steevanb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![version](https://img.shields.io/badge/alpha-0.3.3-red.svg)](https://github.com/steevanb/php-url-test/tree/0.3.3)\n![Lines](https://img.shields.io/badge/code%20lines-4479-green.svg)\n![Total Downloads](https://poser.pugx.org/steevanb/php-url-test/downloads)\n\n## php-url-test\n\nTests all urls of your application\n\n![Url test](example.jpg)\n\n[Changelog](changelog.md)\n\n## Installation\n\n/!\\ Keep in mind this is an alpha version /!\\\n\nDon't allow to update minor/bug fix versions, as we can break compatibility between bug fixes until final release.\n\n```bash\ncomposer require --dev steevanb/php-url-test 0.3.*\n```\n\n## Use it with official Docker image\n\nInstead of install it in your project with Composer, you can use official Docker image.\n\n```bash\ndocker run \\\n    # Create a volume with your test configurations into /app\n    -v /var/www/tests:/app \\\n    # You can use `URLTEST_PARAMETERS` env variable to add parameters to `urltest` command.\n    -e URLTEST_PARAMETERS=\"--ansi --configuration=/app/urltest.yml -vvv\" \\\n    # Allow this container to access host domains\n    --net=host \\\n    steevanb/php-url-test:0.3.3\n```\n\n## Launch tests\n\n```bash\n# scan tests/ to find *.urltest.yml files, --recursive=false or -r=false to not do it recursively\n# if urltest.yml file is found into tests/ (not in sub directories), it will be used for default configuration file\nvendor/bin/urltest tests/\n\n# test url_test_foo\nvendor/bin/urltest tests/ url_test_foo\n\n# test url_test_foo and all tests who match preg pattern /^url_test_bar[0..9]{1,}$/\nvendor/bin/urltest tests/ url_test_foo,/^url_test_bar[0..9]{1,}$/\n\n# launch tests from foo.urltest.yml only\nvendor/bin/urltest tests/Tests/foo.urltest.yml\n\n# don't use tests/urltest.yml, use another configuration file\n# if you are a few developers with different domain for each developer,\n# you can create a configuration file by developer and use parameters to configure it\nvendor/bin/urltest tests/ --configuration=tests/foo.yml\n```\n## Read test results and show informations\n\n```bash\n# show only failed test comparison (by default), use -v, -vv or -vvv to get more informations\nvendor/bin/urltest tests/ --reader=steevanb\\\\PhpUrlTest\\\\ResultReader\\\\ConsoleResultReader#error\n\n# show only passed test comparison, use -v, -vv or -vvv to get more informations\nvendor/bin/urltest tests/ --reader=steevanb\\\\PhpUrlTest\\\\ResultReader\\\\ConsoleResultReader#success\n```\n\nYou can create your own ResultReader, by implementing _steevanb\\PhpUrlTest\\ResultReader\\ResultReaderInterface_.\n\nThen you can use it as you use ConsoleResultReader, with `--reader` parameter.\n\nYou can separate readers by `,`:\n```bash\nvendor/bin/urltest tests/ --reader=steevanb\\\\PhpUrlTest\\\\ResultReader\\\\ConsoleResultReader#error,Foo\\\\Bar#success,Foo\\\\Baz\n```\n\n## Stop on error and resume your tests\n\nYou have 3 parameters to stop tests when a test fail, and resume tests from the one who fail, or skip it and continue after this one :\n\n```bash\n# stop when a test fail\nvendor/bin/urltest tests/ --stop-on-error\n\n# when a test fail, continue testing since the one who fail (do not re-test previous ones)\nvendor/bin/urltest tests/ --stop-on-error --continue\n\n# used with --continue, skip last fail test, and continue testing after this one (do not re-test previous ones)\nvendor/bin/urltest tests/ --skip\n```\n\n## Change directory where UrlTest could write files\n\n```bash\nvendor/bin/urltest tests/ --var-path=/foo\n```\n\n## Dump configuration\n\n```bash\n# dump only global configuration\nvendor/bin/urltest --dump-configuration tests/\n\n# dump global configuration, and url_test_foo configuration\nvendor/bin/urltest --dump-configuration tests/ url_test_foo\n\n# dump global configuration, url_test_foo configuration and all configurations who id match preg pattern /^url_test_bar[0..9]{1,}$/\nvendor/bin/urltest --dump-configuration tests/ url_test_foo,/^url_test_bar[0..9]{1,}$/\n```\n\n## YAML test file example\n\nOnly _request.url_ is required.\n\n```yaml\ntestId:\n    # If abstract = true, this test will not be launched. you can use it as default configuration with parent: testId in another test\n    abstract: false\n    # Id of parent default configuration\n    parent: ~\n    # 0 is first. don't use negative numbers, it's used by UrlTest\n    position: 0\n    events:\n        # Commands called before the test. it could be a string (for only one command) or an array of commands.\n        beforeTest:\n            - command\n        # Commands called after the test. it could be a string (for only one command) or an array of commands.\n        afterTest:\n            - commands\n    request:\n        # You can use parameters (see above) to configure what you need\n        url: '%domain%/foo'\n        timeout: 30\n        port: 80\n        method: GET\n        userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36\n        referer: http://referer.com\n        allowRedirect: true\n        # List of headers to add to request\n        headers:\n            X-Foo: bar\n    expectedResponse:\n        url: http://test.dev\n        code: 200\n        size: 300\n        contentType: text/html\n        numConnects: 1\n        # Set count if you know exaclty number of redirects you want to test, or min/max\n        redirect:\n            min: 1\n            max: 1\n            count: 1\n        header:\n            size: 200\n            # List of headers who has to exists, and have exaclty this value\n            headers:\n                X-Foo: bar\n            # List of headers should not exists\n            unallowedHeaders:\n                - X-Bar\n        body:\n            # Content to compare with response, \u003cfile($fileName)\u003e will get content of $fileName\n            content: \u003cfile('content.html')\u003e\n            size: 100\n            # Transformer id : transform data from content key before comparing it to response\n            transformer: json\n            # File name where tranformed expected content will be saved, if you need to test your transformer for example\n            fileName: /tmp/urlTestResult/expectedResponse.html\n    response:\n        body:\n            # Transformer id : transform data from response body before comparing it to expected response\n            transformer: json\n            # File name where response body will be saved\n            fileName: /tmp/urlTestResult/response.html\n```\n\nYou can define default configurations for all tests in your _.urltest.yml_ file :\n```yaml\n_defaults:\n    # here you can define sames configurations as for a test\n    # this configurations will be applied to all tests in this file, if value is not defined, null or ~\n```\n\n## ResponseBodyTransformer\n\nA response body transformer will modify response body at 2 differents steps:\n * `expectedResponse.body.transformer`: transform expected response\n * `response.body.transformer`: transform response\n\nList of available transformers:\n * `json`: try to decode and reencode value, will transform response to null if data is not a valid JSON\n * `uuid`: try to decode response (should be a valid JSON) and replace all UUID value by `____UUID____`\n\n## Create your own ResponseBodyTransformer\n\nTo create your own ResponseBodyTransformer, you have to do this steps:\n * Create a class who implement `steevanb\\PhpUrlTest\\ResponseBodyTransformer\\ResponseBodyTransformerInterface`\n * Register your ResponseBodyTransformer with `UrlTest::addResponseBodyTransformer()`\n\n## Global configuration file\n\nYou can define global configurations in _urltest.yml_.\n\nThis configurations will be applied to all tests.\n\n```yaml\n# you can define tests here, or abstract tests to use it in all your tests\nurltest:\n    abstractTestId:\n        abstract: true\n        url: http://test.dev\n\n# parameters can be used in almost all urltest configurations\n# define it's value here, and use it with %parameterName% in your configuration\nparameters:\n    domain: 'http://foo.local'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteevanb%2Fphp-url-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteevanb%2Fphp-url-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteevanb%2Fphp-url-test/lists"}