Skip to content

Commit

Permalink
Merge a28b481 into 83636c0
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Apr 6, 2021
2 parents 83636c0 + a28b481 commit f7db90c
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 86 deletions.
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Tests and linting

on:
push:
pull_request:
schedule:
- cron: '0 3 * * *'

jobs:
unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
php-version: ['7.4']
dependencies: ['']
include:
- { php-version: '7.4', dependencies: '--prefer-lowest --prefer-stable' }

name: Unit tests - PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, zip
coverage: xdebug
tools: composer:v2

- name: Install dependencies
run: composer update --no-interaction ${{ matrix.dependencies }}

- name: Run tests
env:
COLUMNS: 120
run: |
composer tests-ci
- name: Submit coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: ${{ github.job }}-PHP-${{ matrix.php-version }} ${{ matrix.dependencies }}
run: |
composer global require php-coveralls/php-coveralls
~/.composer/vendor/bin/php-coveralls --coverage_clover=./code-coverage/clover.xml --json_path=./code-coverage/coveralls-upload.json -v
finish-tests:
name: Tests finished
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- name: Notify Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

codestyle:
name: "Code style and static analysis"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
tools: composer:v2

- name: Install dependencies
run: composer update --no-progress

- name: Run checks
run: composer analyze
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/code-coverage/
composer.lock

.phpunit.result.cache

# tools
/tools/**
!/tools/*/composer.json
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->
## Unreleased
- [**BC**] Require php 7.4 and update dependencies
- [**BC**] Drop Symfony 4 support

## 1.1.0 - 2019-11-28
- Update dependencies
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ or
```

## Requirements
- `PHP 7.1`
- `PHP 7.4`
- [league/csv](https://github.com/thephpleague/csv)

## Usage

> For detail explanation see [this issue](https://github.com/MortalFlesh/csv-exporter/issues/2#issuecomment-782130283)
### In Symfony Controller action
```php
return (new StreamedResponseFactory(/* ...dependencies */)) // from ->get('service')
Expand Down
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
}
},
"require": {
"php": "^7.1",
"php": "^7.4",
"league/csv": "^5.0",
"symfony/http-foundation": "^2.8 || ^3.3 || ^4.0 || ^5.0"
"symfony/http-foundation": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"phpstan/phpstan": "^0.11.0",
"mockery/mockery": "^1.0",
"satooshi/php-coveralls": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-mockery": "^0.11.3"
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.4",
"phpstan/phpstan": "^0.12.83",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-phpunit": "^0.12.18",
"phpstan/phpstan-mockery": "^0.12.13"
},

"scripts": {
"post-install-cmd": [
"@installTools"
Expand All @@ -47,6 +48,7 @@
"@phpstan"
],
"test": "vendor/bin/phpunit -c phpunit.xml.dist",
"tests-ci": "php -dxdebug.coverage_enable=1 vendor/bin/phpunit -c phpunit.xml.dist",
"phpstan": "vendor/bin/phpstan analyse -l 5 -c phpstan.neon src tests",
"fix": [
"vendor/bin/ecs check --ansi --clear-cache --fix -- src/ tests/"
Expand Down
6 changes: 0 additions & 6 deletions easy-coding-standard.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/tools/coding-standards/vendor/lmc/coding-standard/ecs.php');
};
56 changes: 23 additions & 33 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php">
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="./code-coverage/clover.xml"/>
<html outputDirectory="./code-coverage" highLowerBound="90"/>
</report>
</coverage>

<php>
<!-- E_ALL = 30719 -->
<ini name="error_reporting" value="30719"/>
</php>

<testsuites>
<testsuite name="MF/CSVExporter Test Suite">
<directory>./tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<directory>src/Exception</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="./code-coverage" title="MF/CSVExporter"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="90"/>

<log type="coverage-clover" target="./code-coverage/clover.xml"/>
<log type="junit" target="./code-coverage/junit.xml" logIncompleteSkipped="false"/>
<junit outputFile="./code-coverage/junit.xml"/>
</logging>

<php>
<!-- E_ALL = 30719 -->
<ini name="error_reporting" value="30719"/>
</php>
</phpunit>
3 changes: 1 addition & 2 deletions src/CsvStreamRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

class CsvStreamRenderer
{
/** @var CsvWriterFactory */
private $csvWriterFactory;
private CsvWriterFactory $csvWriterFactory;

public function __construct(CsvWriterFactory $csvWriterFactory)
{
Expand Down
5 changes: 2 additions & 3 deletions src/DataStreamGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

class DataStreamGenerator
{
const DEFAULT_BULK_SIZE = 1000;
public const DEFAULT_BULK_SIZE = 1000;

/** @var CsvStreamRenderer */
private $csvStreamRenderer;
private CsvStreamRenderer $csvStreamRenderer;

/** @var callable */
private $formatRowData;
Expand Down
3 changes: 1 addition & 2 deletions src/Factory/StreamedResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

class StreamedResponseFactory
{
/** @var DataStreamGenerator */
private $dataStreamGenerator;
private DataStreamGenerator $dataStreamGenerator;

public function __construct(DataStreamGenerator $dataStreamGenerator)
{
Expand Down
7 changes: 2 additions & 5 deletions tests/CsvStreamRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

class CsvStreamRendererTest extends AbstractTestCase
{
/** @var CsvStreamRenderer */
private $csvStreamRenderer;

/** @var CsvWriterFactory */
private $csvWriterFactory;
private CsvStreamRenderer $csvStreamRenderer;
private CsvWriterFactory $csvWriterFactory;

protected function setUp(): void
{
Expand Down
5 changes: 2 additions & 3 deletions tests/DataStreamGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

class DataStreamGeneratorTest extends AbstractTestCase
{
/** @var DataStreamGenerator */
private $dataStreamGenerator;
private DataStreamGenerator $dataStreamGenerator;

/** @var CsvStreamRenderer|m\MockInterface */
private $csvStreamRenderer;
private CsvStreamRenderer $csvStreamRenderer;

protected function setUp(): void
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Factory/StreamedResponseFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

class StreamedResponseFactoryTest extends AbstractTestCase
{
/** @var StreamedResponseFactory */
private $streamedResponseFactory;
private StreamedResponseFactory $streamedResponseFactory;

/** @var DataStreamGenerator|m\Mock */
private $dataStreamGenerator;
Expand Down
4 changes: 2 additions & 2 deletions tools/coding-standards/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tools/coding-standards",
"require-dev": {
"lmc/coding-standard": "^1.0"
"lmc/coding-standard": "^3.0"
},
"authors": [
{
Expand All @@ -14,7 +14,7 @@
},
"config": {
"platform": {
"php": "7.1.1"
"php": "7.4.16"
},
"sort-packages": true
}
Expand Down

0 comments on commit f7db90c

Please sign in to comment.