Commit 3103e38e authored by Protocole's avatar Protocole
Browse files

Initial version phpunit_test

parent 5ce54db8
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
# 🐘 PHPUnit Testing

## Description

Using this job you'll be able to launch PHPUnit tests. You need nothing more than a valid phpunit.xml.

Results of tests are available in a report named `report-phpunit.xml` as an artifact.

## How to use it

1. Have a valid `phpunit.xml` in the root of your project. See [Variables]( #variables) if it is not in the root.
2. Add the corresponding URL to your `.gitlab-ci.yml` file (see [Getting
   started](/getting-started)). Example:

    ```yaml
    include:
      - remote: 'https://jobs.go2scale.io/phpunit_test.yml'
    ```

3. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/getting-started/#jobs-customization)
4. Well done, your job is ready to work ! 😀

## Job details

* Job name: `phpunit_test`
* Docker image:
[`lorisleiva/laravel-docker:7.3`](https://hub.docker.com/r/lorisleiva/laravel-docker)
* Default stage: `static_tests`
* When: `always`


### Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `PHPUNIT_VERBOSITY` <img width=250/> | Define the verbosity of PHPUnit | `v` |
| `PROJECT_ROOT` <img width=250/> | Define where your project and the phpunit.xml are | `/` |
+6 −0
Original line number Diff line number Diff line
name: phpunit_test
description: A ready to use php environnement that launches phpunit testings
default_stage: static_tests
icon: 🐘
maintainer: Protocole
license: MIT
 No newline at end of file
+22 −0
Original line number Diff line number Diff line
stages:
  - static_tests

phpunit_test:
    image: lorisleiva/laravel-docker:7.3
    stage: static_tests
    variables:
      PHPUNIT_VERBOSITY: "v"
      PROJECT_ROOT: "/"
    script:
      # Going to the root of php project
      - cd ${CI_PROJECT_DIR}${PROJECT_ROOT}
      # Running Unit testing
      - phpunit -${PHPUNIT_VERBOSITY} --coverage-text --colors=never --stderr --log-junit report-phpunit.xml
    artifacts:
      when: always
      expire_in: never
      paths:
        - ${CI_PROJECT_DIR}${PROJECT_ROOT}/report-phpunit.xml
        - ${CI_PROJECT_DIR}${PROJECT_ROOT}/storage/logs
      reports:
        junit: ${CI_PROJECT_DIR}${PROJECT_ROOT}/report-phpunit.xml
+1 −0
Original line number Diff line number Diff line
* Initial version
 No newline at end of file