Commit bf110d18 authored by Alexandre Burgoni's avatar Alexandre Burgoni
Browse files

Update PHPUnit to 0.2.0

parent 1a76e0ae
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -37,11 +37,22 @@ Using this job you'll be able to launch PHPUnit tests.
| `PHPUNIT_CONFIG_FILE` | Config file source in repository | `phpunit.xml` |
| `PHPUNIT_COLORS` | Use colors in output | `never` |
| `PHPUNIT_OPTIONS` | Custom user options for phpunit | ` ` |
| `PHPUNIT_MEMORY_LIMIT` | Memory available for PHPUnit (see [more](#php-memory-limit)) | `512M` |
| `PROJECT_ROOT` | PHP Project location | `/` |

!!! note
    All paths defined in variables are starting from the root of your repository.

### PHP Memory Limit

PHP default configuration limits the RAM used by a script with a limit of `128 MB`, this job elevates this limit to `512 MB`.
But, with this higher value, when you run a large amount of tests you may experience a **lack of memory** resulting in a job's failure.

The error generated by this problem may have the following format:
```
Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x bytes) in /path/to/project/root
```

### Artifacts

We use [Junit](https://junit.org/junit5/){:target="_blank"}'s XML report to display error report
+6 −2
Original line number Diff line number Diff line
@@ -11,14 +11,18 @@ phpunit_test:
      PHPUNIT_CONFIG_FILE: "phpunit.xml"
      PHPUNIT_COLORS: "never"
      PHPUNIT_OPTIONS: ""
      PHPUNIT_MEMORY_LIMIT: "512M"
      PROJECT_ROOT: "/"
    script:
      # Installing globally PhpUnit
      # Installing globally PHPUnit if not already
      - composer global require "phpunit/phpunit"
      # Going to the root of php project
      - cd ${CI_PROJECT_DIR}${PROJECT_ROOT}
      # Running Unit testing
      - phpunit --configuration ${PHPUNIT_CONFIG_FILE} --coverage-text --colors=${PHPUNIT_COLORS} --log-junit ${CI_PROJECT_DIR}/${PHPUNIT_OUTPUT} ${PHPUNIT_OPTIONS}
      - phpunit \
        -d memory_limit=${PHPUNIT_MEMORY_LIMIT} --configuration ${PHPUNIT_CONFIG_FILE} \
        --coverage-text --colors=${PHPUNIT_COLORS} \
        --log-junit ${CI_PROJECT_DIR}/${PHPUNIT_OUTPUT} ${PHPUNIT_OPTIONS} 
    artifacts:
      when: always
      paths:
+1 −0
Original line number Diff line number Diff line
* New variable `PHPUNIT_MEMORY_LIMIT`, adds possibility to increase memory_limit of PHP
 No newline at end of file