Files
FreshRSS/docs/en/developers/03_Running_tests.md
dependabot[bot] 7d86cbe804 Bump markdownlint-cli from 0.44.0 to 0.45.0 (#7632)
* Bump markdownlint-cli from 0.44.0 to 0.45.0

Bumps [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) from 0.44.0 to 0.45.0.
- [Release notes](https://github.com/igorshubovych/markdownlint-cli/releases)
- [Commits](https://github.com/igorshubovych/markdownlint-cli/compare/v0.44.0...v0.45.0)

---
updated-dependencies:
- dependency-name: markdownlint-cli
  dependency-version: 0.45.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix Markdown

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2025-06-01 22:50:58 +02:00

3.2 KiB
Raw Blame History

Running tests

FreshRSS is tested with PHPUnit, PHPStan, PHP_CodeSniffer, and more. No code should be merged in edge if the tests dont pass.

Locally

As a developer, you can run the test suite on your PC easily with make commands. You can run the test suite with:

cd ./FreshRSS/
make test-all

Some syntax, formatting, whitespace, and i18n conventions can be fixed automatically with:

make fix-all

Some tests can run inside some Docker images, in particular to test against minimum and maximum versions of PHP:

# Prepare
make composer-test
docker build --pull --tag freshrss/freshrss:oldest -f Docker/Dockerfile-Oldest .
docker build --pull --tag freshrss/freshrss:newest -f Docker/Dockerfile-Newest .

# Run
docker run --rm -e FRESHRSS_ENV=development -e TZ=UTC -v $(pwd):/var/www/FreshRSS freshrss/freshrss:oldest bin/composer test
docker run --rm -e FRESHRSS_ENV=development -e TZ=UTC -v $(pwd):/var/www/FreshRSS freshrss/freshrss:newest bin/composer test

GitHub Actions for Continuous Integration

Tests are automatically run when you open a pull request on GitHub. They are performed with GitHub Actions. This ensures your code will not introduce some kind of regression. We will not merge a PR if tests fail so we will ask you to fix any bugs before reviewing your code.

If you are interested, you can take a look at the configuration file.

Using feed snapshots

As feed data is volatile, its better to work with snapshots when debugging some issues. Check the description to retrieve a snapshot.

To serve those snapshots, you can use a mock server. Here we will demonstrate how to work with WireMock but other solutions exist. Here are the steps to start using the WireMock mock server:

  1. Go to the mock server home folder. If you do not have one, you need to create one.
  2. Inside the mock server home folder, create the __file and mappings folders.
  3. Copy or move your snapshots in the __file folder.
  4. Create the feed.json file in the mappings folder with the following content:
    {
    	"request": {
    		"method": "GET",
    		"urlPathPattern": "/.*"
    	},
    	"response": {
    		"status": 200,
    		"bodyFileName": "{{request.pathSegments.[0]}}",
    		"transformers": ["response-template"],
    		"headers": {
    			"Content-Type": "application/rss+xml"
    		}
    	}
    }
    
  5. Launch the containerized server with the following command:
    # <PORT> is the port used on the host to communicate with the server
    # <NETWORK> is the name of the docker network used (by default, its freshrss-network)
    docker run -it --rm -p <PORT>:8080 --name wiremock --network <NETWORK> -v $PWD:/home/wiremock wiremock/wiremock:latest-alpine --local-response-templating
    
  6. You can access the <RSS> mock file directly:
    • from the host by sending a GET request to http://localhost:<PORT>/<RSS>,
    • from any container connected on the same network by sending a GET request to http://wiremock:8080/<RSS>.