omise / omise-prestashop

Omise PrestaShop Plugin
https://docs.opn.ooo/prestashop-plugin
MIT License
4 stars 7 forks source link

Modify the unit test, create mock object syntax, to support with PHP 5.4 #22

Closed guzzilar closed 7 years ago

guzzilar commented 7 years ago

Note, original PR was introduced by @nimid at PR #15. This PR just did rebase #19 into the branch and then reopen it again. (read here, for the reason)

This PR required PR #19 to be merged first.

1. Objective

Support running the unit test with PHP 5.4.

According to the PrestaShop system requirements page, it stated that the supported PHP version is from 5.4 onwards. To ensure that the source code is compatible with those PHP versions, it can be tested at the unit testing level as well.

But when run the unit testing with PHP 5.4, the error is PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/travis/build/nimid/omise-prestashop/tests/unit/OmiseTest.php on line 10.

The error only occurs with PHP 5.4.

The error related with the ::class syntax. This syntax has been support since PHP 5.5.

Related information: Related issue: - Related ticket: -

2. Description of change

Changes the syntax that used to create mock object in part of unit testing. The syntax has been changed from the full class name reference to using the internal PHP function, get_class.

3. Quality assurance

Environments:

Details:

Manual testing Run the unit testing with PHPUnit (no additional required parameters). For example:

$ phpunit

Automated testing Setup the system such as Travis CI, CircleCI or Jenkins.

4. Impact of the change

-

5. Priority of change

Low

6. Additional notes

The screenshot below shows the error at Travis CI.

error_on_travis_ci

The screenshot below shows the error at CircleCI.

error_on_circleci

The screenshot below shows the supported PHP version on PrestaShop system requirements page.

screenshot-www prestashop com 2017-01-04 13-59-05

guzzilar commented 7 years ago

LGTM 👍

Waiting #19 to be merged.