Skip to content

Commit

Permalink
Merge pull request #29 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Merge dev branch into master branch (released 2.1.0)
  • Loading branch information
Mickaël Andrieu authored Oct 23, 2018
2 parents 79d8645 + 92e7ebb commit 13bfd12
Show file tree
Hide file tree
Showing 708 changed files with 3,009 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
data/data_*
views/css/advice-*
vendor/
.php_cs.cache
55 changes: 55 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
language: php

addons:
apt:
packages:
- apache2
- postfix
- libapache2-mod-fastcgi
- libappindicator1
- fonts-liberation

cache:
directories:
- $HOME/.composer/cache

sudo: required
dist: trusty

php:
- "5.6"
- "7.1"
- "7.2"

env:
global:
- SYMFONY_DEPRECATIONS_HELPER=disabled
- SYMFONY_PHPUNIT_VERSION=5.7
- MODULE_DIR=/tmp/gamification
- MODULE_SCRIPTS_DIR=/tmp/gamification/tools

matrix:
- PS_VERSION=1.7.4.x
- PS_VERSION=1.7.5.x

allow_failures:
- php: 7.2

fast_finish: true

before_script:
- ./tools/move_module.sh
- $MODULE_SCRIPTS_DIR/get_prestashop.sh
- $MODULE_SCRIPTS_DIR/install_webserver.sh
- $MODULE_SCRIPTS_DIR/start_prestashop.sh
- $MODULE_SCRIPTS_DIR/install_module.sh gamification

script:
- cd $TRAVIS_BUILD_DIR/modules/gamification
- composer cs-fix-test
- composer test

notifications:
email:
on_success: never
on_failure: always
8 changes: 8 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ That's it: you have contributed to this open-source project! Congratulations!
[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
[3]: https://help.github.com/articles/using-pull-requests

### Execute the testsuite

This module is shipped with a testsuite using PHPUnit, you need Composer to install the dependencies:

```
composer install
composer test
```
4 changes: 2 additions & 2 deletions classes/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Badge extends ObjectModel

public $awb;

const BAGDE_IMG_URL = 'gamification.prestashop.com/api/getBadgeImg';
const BAGDE_IMG_URL = '../modules/gamification/views/img/badges/';

/**
* @see ObjectModel::$definition
Expand All @@ -75,7 +75,7 @@ class Badge extends ObjectModel

public function getBadgeImgUrl()
{
return Tools::getShopProtocol().self::BAGDE_IMG_URL.'/'.(int)$this->id_ps_badge.'/'.(int)$this->validated.'.png';
return self::BAGDE_IMG_URL .(int)$this->id_ps_badge.'_'.(int)$this->validated.'.png';
}

public function validate()
Expand Down
30 changes: 30 additions & 0 deletions classes/GamificationTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ public static function parseMetaData($content)
$content = preg_replace_callback('#\{language\}(.*)\{/language\}#', create_function('$matches', 'return Context::getContext()->language->$matches[1];'), $content);
$content = preg_replace_callback('#\{country\}(.*)\{/country\}#', create_function('$matches', 'return Context::getContext()->country->$matches[1];'), $content);

return $content;
}

/**
* Retrieve Json api file, forcing gzip compression to save bandwith.
* @param string $url
* @param bool $withResponseHeaders
* @return string|bool
*/
public static function retrieveJsonApiFile($url, $withResponseHeaders = false)
{
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_MAXREDIRS, 2);
// @see https://cloud.google.com/appengine/kb/#compression
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
curl_setopt($curl, CURLOPT_USERAGENT, 'gzip');
curl_setopt($curl, CURLOPT_HEADER, $withResponseHeaders);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, $withResponseHeaders);

$content = curl_exec($curl);

curl_close($curl);


return $content;
}
}
14 changes: 13 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@
}
],
"require": {
"php": ">=5.4"
"php": ">=5.6"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.12",
"phpunit/phpunit": "~5.7",
"mockery/mockery": "^1.2",
"symfony/phpunit-bridge": "^3.4",
"symfony/debug": "^3.4"
},
"config": {
"preferred-install": "dist"
},
"scripts": {
"cs-fix": "@php ./vendor/bin/php-cs-fixer fix .",
"cs-fix-test": "@php ./vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --show-progress=dot .",
"test": "SYMFONY_PHPUNIT_VERSION=5.7 php ./vendor/bin/simple-phpunit"
},
"type": "prestashop-module"
}
Loading

0 comments on commit 13bfd12

Please sign in to comment.