Skip to content

Commit

Permalink
fixed php8
Browse files Browse the repository at this point in the history
  • Loading branch information
HillLiu committed Aug 6, 2023
1 parent 3c613d1 commit 5723af7
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 45 deletions.
57 changes: 57 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: 2.1

jobs:
unittest:
parameters:
php-version:
type: string
plugin-name:
type: string
default: "getenv"
docker:
- image: hillliu/pmvc-phpunit:<< parameters.php-version >>
working_directory: /var/www/<< parameters.plugin-name >>
steps:
- checkout
- run:
name: "Display information"
command: |
date
php -v
php -m
composer --version
phpunit --version
- run:
name: Composer install packages
command: |
composer update
composer install --prefer-source
- run:
name: PHPUnit
command: |
ENABLE_COVERAGE=false
if [ "<< parameters.php-version >>" == "8.2" ]; then
if [ "$ENABLE_COVERAGE" == "true" ]; then
XDEBUG_MODE=coverage phpunit --coverage-clover clover.xml
coveralls --coverage_clover=clover.xml -v -o coveralls-upload.json
else
phpunit --display-deprecations
fi
else
phpunit
fi
- store_artifacts:
path: /var/www/<< parameters.plugin-name >>/clover.xml
- store_artifacts:
path: /var/www/<< parameters.plugin-name >>/coveralls-upload.json
- store_test_results:
path: /tmp/test_output

workflows:
run-job:
jobs:
- unittest:
matrix:
parameters:
php-version: ["8.2", "8.1", "8.0", "5.6"]

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor
composer.lock
.php_cs.cache
.phpunit.cache
.phpunit.result.cache
.*.sw?
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Latest Stable Version](https://poser.pugx.org/pmvc-plugin/getenv/v/stable)](https://packagist.org/packages/pmvc-plugin/getenv)
[![Latest Unstable Version](https://poser.pugx.org/pmvc-plugin/getenv/v/unstable)](https://packagist.org/packages/pmvc-plugin/getenv)
[![Build Status](https://travis-ci.org/pmvc-plugin/getenv.svg?branch=master)](https://travis-ci.org/pmvc-plugin/getenv)
[![CircleCI](https://circleci.com/gh/pmvc-plugin/getenv/tree/main.svg?style=svg)](https://circleci.com/gh/pmvc-plugin/getenv/tree/main)
[![License](https://poser.pugx.org/pmvc-plugin/getenv/license)](https://packagist.org/packages/pmvc-plugin/getenv)
[![Total Downloads](https://poser.pugx.org/pmvc-plugin/getenv/downloads)](https://packagist.org/packages/pmvc-plugin/getenv)

Expand All @@ -11,7 +11,7 @@ PMVC Getenv Plugin

# How to use
* check the unit test funciotn testGet
* https://github.com/pmvc-plugin/getenv/blob/master/test.php#L17
* https://github.com/pmvc-plugin/getenv/blob/main/test.php#L17



Expand All @@ -26,7 +26,7 @@ PMVC Getenv Plugin
```
{
"require": {
"pmvc-plugin/getenv": "dev-master"
"pmvc-plugin/getenv": "dev-main"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion getenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function init()
$isCache = true;
$site = $this->getDefault(
'SITE',
basename(\PMVC\callPlugin('controller', 'getAppsParent'))
basename(\PMVC\callPlugin('controller', 'getAppsParent') || '')
);
return $site;
};
Expand Down
35 changes: 19 additions & 16 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="tests/include.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/include.php"
processIsolation="false"
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
<file>./tests/test.php</file>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="true"/>
<ini name="display_startup_errors" value="true"/>
<env name="APP_ENV" value="testing"/>
<ini name="error_reporting" value="E_ALL" />
<ini name="display_errors" value="true" />
<ini name="display_startup_errors" value="true" />
<env name="APP_ENV" value="testing" />
</php>
<logging>
<junit outputFile="/tmp/test_output/junit.xml" />
</logging>
</phpunit>
8 changes: 4 additions & 4 deletions src/_utm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PMVC\PlugIn\getenv;

${_INIT_CONFIG}[_CLASS] = __NAMESPACE__.'\utm';
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\utm';

class utm
{
Expand All @@ -13,18 +13,18 @@ function __invoke($key)
$arr = [];
$request = $this->caller->request();
foreach ($rawKeys as $rawK) {
$kVal = \PMVC\get($request, 'utm_'.$rawK);
$kVal = \PMVC\get($request, 'utm_' . $rawK, '');
$kVal = str_replace('_', '', $kVal);
if (empty($kVal)) {
$isEmpty = true;
break;
}
$arr[] = $kVal;
$arr[] = $kVal;
}
$pCookie = \PMVC\plug('cookie');
if (!$isEmpty) {
$utm = join('_', $arr);
$pCookie->set($key, $utm, ['lifetime'=>86400*365]);
$pCookie->set($key, $utm, ['lifetime' => 86400 * 365]);
return $utm;
}
$utm = $pCookie->get($key);
Expand Down
File renamed without changes.

0 comments on commit 5723af7

Please sign in to comment.