Skip to content

Commit dc183b3

Browse files
author
Igor Chepurnoy
authored
Merge pull request #26 from yii2mod/feature-fix-compatibility-with-php-72
Fix compatibility with php 7.2
2 parents d2281bd + f338b6b commit dc183b3

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: php
22

33
php:
4-
- 7.0
54
- 7.1
5+
- 7.2
66

77
# faster builds on new travis setup not using sudo
88
sudo: false

composer.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,26 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.0.0",
18-
"yiisoft/yii2": "*"
17+
"php": ">=7.1.0",
18+
"yiisoft/yii2": "~2.0.10"
1919
},
2020
"require-dev": {
2121
"friendsofphp/php-cs-fixer": "~2.0",
22-
"phpunit/phpunit": "~6.0"
22+
"phpunit/phpunit": "^7.3"
2323
},
2424
"autoload": {
2525
"psr-4": {
2626
"yii2mod\\cart\\": ""
2727
}
2828
},
29+
"scripts": {
30+
"phpcs": "php-cs-fixer fix -v --diff --dry-run --allow-risky=yes;",
31+
"phpunit": "phpunit --coverage-text",
32+
"test": [
33+
"@phpunit",
34+
"@phpcs"
35+
]
36+
},
2937
"repositories": [
3038
{
3139
"type": "composer",

storage/DatabaseStorage.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace yii2mod\cart\storage;
44

55
use Yii;
6+
use yii\base\BaseObject;
67
use yii\base\InvalidConfigException;
7-
use yii\base\Object;
88
use yii\db\Connection;
99
use yii\db\Query;
1010
use yii\web\User;
@@ -18,7 +18,7 @@
1818
*
1919
* @package yii2mod\cart\storage
2020
*/
21-
class DatabaseStorage extends Object implements StorageInterface
21+
class DatabaseStorage extends BaseObject implements StorageInterface
2222
{
2323
/**
2424
* @var string Name of the user component

tests/TestCase.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Yii;
66
use yii\helpers\ArrayHelper;
7+
use yii2mod\cart\tests\data\Session;
78

89
/**
910
* This is the base class for all yii framework unit tests.
@@ -43,7 +44,7 @@ protected function mockApplication($config = [], $appClass = '\yii\console\Appli
4344
'dsn' => 'sqlite::memory:',
4445
],
4546
'session' => [
46-
'class' => 'yii\web\DbSession',
47+
'class' => Session::class,
4748
],
4849
'cart' => [
4950
'class' => 'yii2mod\cart\Cart',

tests/data/Session.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace yii2mod\cart\tests\data;
4+
5+
class Session extends \yii\web\Session
6+
{
7+
/**
8+
* @inheritdoc
9+
*/
10+
public function init()
11+
{
12+
// blank, override, preventing shutdown function registration
13+
}
14+
15+
/**
16+
* @inheritdoc
17+
*/
18+
public function open()
19+
{
20+
// blank, override, preventing session start
21+
}
22+
}

0 commit comments

Comments
 (0)