Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise min version to PHP 7.3, check compatibility PHP 8.3. #369

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
117 changes: 65 additions & 52 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,70 @@
name: build
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

on: [push, pull_request]
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
name: build

jobs:
phpunit:
name: PHP ${{ matrix.php }} (mongodb ${{ matrix.mongoext }}) on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
services:
mongodb:
image: mongo:${{ matrix.mongo }}
ports:
phpunit:
name: PHP ${{ matrix.php }} (mongodb ${{ matrix.mongoext }}) on ${{ matrix.os }}

runs-on: ${{ matrix.os }}

services:
mongodb:
image: mongo:${{ matrix.mongo }}
ports:
- 27017:27017
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
mongo: ['3']
mongoext: ['1.8.2', '1.9.0']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: mongodb-${{ matrix.mongoext }}
ini-values: date.timezone='UTC'
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: Run unit tests with coverage
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always
if: matrix.php == '7.1'
- name: Run unit tests without coverage
run: vendor/bin/phpunit --verbose --colors=always
if: matrix.php != '7.1'
- name: Upload code coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
if: matrix.php == '7.1'
continue-on-error: true # if is fork
strategy:
matrix:
os: [ubuntu-latest]
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
mongo: ['3']
mongoext: ['1.8.2', '1.9.0']

steps:
- name: Checkout.
uses: actions/checkout@v2

- name: Install PHP.
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: mongodb-${{ matrix.mongoext }}
ini-values: date.timezone='UTC'

- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit.
if: matrix.php != '8.1'
run: vendor/bin/phpunit --colors=always

- name: Run tests with phpunit and generate coverage.
if: matrix.php == '8.1'
run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always

- name: Upload coverage to Codecov.
if: matrix.php == '8.1'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
39 changes: 39 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
checks:
php: true

filter:
paths:
- src/

build:
image: default-bionic

environment:
php:
version: 8.0.18
ini:
xdebug.mode: coverage

nodes:
analysis:
tests:
override:
- php-scrutinizer-run

phpunit:
services:
mongo-db:
image: mongo:3

ports:
- 27017

dependencies:
override:
- pecl install mongodb
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
- command: ./vendor/bin/phpunit
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-mongodb/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-mongodb)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-mongodb/downloads.png)](https://packagist.org/packages/yiisoft/yii2-mongodb)
[![Build Status](https://github.com/yiisoft/yii2-mongodb/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-mongodb/actions)
[![codecov](https://codecov.io/gh/yiisoft/yii2-mongodb/graph/badge.svg?token=1Xo867R6He)](https://codecov.io/gh/yiisoft/yii2-mongodb)

Requirements
------------

- PHP 7.3 or higher.

Installation
------------
Expand Down
19 changes: 3 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.39",
"php": ">=7.3",
"ext-mongodb": ">=1.0.0",
"paragonie/random_compat": ">=1"
"yiisoft/yii2": "~2.0.39"
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
"phpunit/phpunit": "^9.6"
},
"repositories": [
{
Expand All @@ -38,22 +37,10 @@
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
},
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch",
"Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php81.patch"
}
}
},
"config": {
"allow-plugins": {
"cweagans/composer-patches": true,
"yiisoft/yii2-composer": true
}
}
Expand Down
36 changes: 25 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Yii2-mongodb Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./tests/bootstrap.php"
colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>

<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Yii2-MongoDb">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions tests/ActiveDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

class ActiveDataProviderTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->mockApplication();
ActiveRecord::$db = $this->getConnection();
$this->setUpTestRows();
}

protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection(Customer::collectionName());
parent::tearDown();
Expand Down
6 changes: 3 additions & 3 deletions tests/ActiveFixtureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

class ActiveFixtureTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->mockApplication();
}

protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection(Customer::collectionName());
FileHelper::removeDirectory(Yii::getAlias('@runtime/fixtures'));
Expand Down Expand Up @@ -163,4 +163,4 @@ class {$className} extends \yii\mongodb\ActiveFixture
$rows = $this->findAll($this->getConnection()->getCollection(Customer::collectionName()));
$this->assertCount(3, $rows);
}
}
}
6 changes: 3 additions & 3 deletions tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class ActiveRecordTest extends TestCase
*/
protected $testRows = [];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
$this->setUpTestRows();
}

protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection(Customer::collectionName());
parent::tearDown();
Expand Down Expand Up @@ -518,4 +518,4 @@ public function testEmulateExecution()
->distinct('name');
$this->assertSame([], $values);
}
}
}
4 changes: 2 additions & 2 deletions tests/ActiveRelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

class ActiveRelationTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
$this->setUpTestRows();
}

protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection(Customer::collectionName());
$this->dropCollection(CustomerOrder::collectionName());
Expand Down
6 changes: 3 additions & 3 deletions tests/BatchQueryResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

class BatchQueryResultTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
ActiveRecord::$db = $this->getConnection();
$this->setUpTestRows();
}

protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection(Customer::collectionName());
$this->dropCollection(CustomerOrder::collectionName());
Expand Down Expand Up @@ -177,4 +177,4 @@ public function testActiveQuery()
$this->assertEquals(2, count($customers[1]->orders));
$this->assertEquals(2, count($customers[2]->orders));
}
}
}
2 changes: 1 addition & 1 deletion tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CacheTest extends TestCase
*/
protected static $cacheCollection = '_test_cache';

protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection(static::$cacheCollection);
parent::tearDown();
Expand Down
2 changes: 1 addition & 1 deletion tests/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class CollectionTest extends TestCase
{
protected function tearDown()
protected function tearDown(): void
{
$this->dropCollection('customer');
$this->dropCollection('mapReduceOut');
Expand Down
Loading
Loading