Skip to content

Commit

Permalink
Updating PHPUnit to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewatts committed Jun 3, 2022
1 parent 96bfaca commit 829e17a
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 138 deletions.
60 changes: 60 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,60 @@
# PHP CircleCI 2.0 configuration file
# See: https://circleci.com/docs/2.0/language-php/
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build:
parameters:
php-version:
type: string
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
# Specify the version you desire here
- image: cimg/php:<< parameters.php-version >>

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# Using the RAM variation mitigates I/O contention
# for database intensive operations.
# - image: circleci/mysql:5.7-ram
#
# - image: redis:2.8.19

resource_class: small

# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout

- run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev

# Download and cache dependencies
- restore_cache:
keys:
# "composer.lock" can be used if it is committed to the repo
- v1-dependencies-{{ checksum "composer.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: composer install -n --prefer-dist

- save_cache:
key: v1-dependencies-{{ checksum "composer.json" }}
paths:
- ./vendor

# run tests with phpunit or codecept
- run: ./vendor/bin/phpunit

workflows:
all-tests:
jobs:
- test:
matrix:
parameters:
php-version: [7.3.30, 7.4.26, 8.0.19, 8.1.5]
29 changes: 0 additions & 29 deletions .php_cs

This file was deleted.

1 change: 1 addition & 0 deletions .phpunit.result.cache
@@ -0,0 +1 @@
{"version":1,"defects":{"Affinity4\\File\\Test\\FileTest::testGet":4,"Affinity4\\File\\Test\\FileTest::testThrowsInvalidArgumentExceptionOnLessThanMinusOne":4,"Affinity4\\File\\Test\\FileTest::testThrowsInvalidArgumentExceptionOnZero":4,"Affinity4\\File\\Test\\FileTest::testUpOne":1,"Affinity4\\File\\Test\\FileTest::testUp":1,"Affinity4\\File\\Test\\FileTest::testParent":1,"Affinity4\\File\\Test\\FileTest::testParents":1,"Affinity4\\File\\Test\\FileTest::testInGet":1,"Affinity4\\File\\Test\\FileTest::testSetFileListUsingPatternWithRegex":3,"Affinity4\\File\\Test\\FileTest::testSetFileListUsingPatternWithFilename":1},"times":{"Affinity4\\File\\Test\\FileTest::testDirsExist":0.004,"Affinity4\\File\\Test\\FileTest::testFilesExist":0.001,"Affinity4\\File\\Test\\FileTest::testFind":0.001,"Affinity4\\File\\Test\\FileTest::testIsValidPattern":0,"Affinity4\\File\\Test\\FileTest::testIn":0.001,"Affinity4\\File\\Test\\FileTest::testGet":0.002,"Affinity4\\File\\Test\\FileTest::testThrowsInvalidArgumentExceptionOnLessThanMinusOne":0.001,"Affinity4\\File\\Test\\FileTest::testThrowsInvalidArgumentExceptionOnZero":0,"Affinity4\\File\\Test\\FileTest::testUpOne":0.003,"Affinity4\\File\\Test\\FileTest::testUp":0.003,"Affinity4\\File\\Test\\FileTest::testParent":0.003,"Affinity4\\File\\Test\\FileTest::testParents":0.005,"Affinity4\\File\\Test\\FileTest::testInGet":0.001,"Affinity4\\File\\Test\\FileTest::testSetFileListUsingPatternWithRegex":0.001,"Affinity4\\File\\Test\\FileTest::testSetFileListUsingPatternWithFilename":0.001}}
71 changes: 0 additions & 71 deletions .scrutinizer.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

11 changes: 7 additions & 4 deletions composer.json
@@ -1,6 +1,6 @@
{
"name": "affinity4/file",
"description": "Recursively search parent directories of a given directory for files with regex pattern or filename",
"description": "Recursively search child (or parent) directories of a given directory for files with regex pattern or filename",
"license": "MIT",
"keywords": ["file", "affinity4"],
"authors": [
Expand All @@ -15,10 +15,13 @@
}
},
"require": {
"php": ">=7.0"
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^6.1",
"phpunit/php-code-coverage": "^5.2"
"phpunit/phpunit": "^9.5",
"phpunit/php-code-coverage": "^9.2"
},
"scripts": {
"test": "vendor/bin/phpunit"
}
}
8 changes: 1 addition & 7 deletions phpunit.xml
Expand Up @@ -8,13 +8,7 @@
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<testsuite name="unit">
<directory suffix="Test.php">tests</directory>
</testsuite>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
30 changes: 11 additions & 19 deletions tests/FileTest.php
Expand Up @@ -40,7 +40,7 @@ class FileTest extends TestCase
*
* @depends testFilesExist
*/
public function setUp()
public function setUp(): void
{
$this->file = new File();
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public function testGet()
$pattern = '/^test[\w\d-]*.txt$/';
$dir = 'tests/files/01/02';

$this->assertInternalType('array', $this->file->find($pattern)->in($dir)->get());
$this->assertIsArray($this->file->find($pattern)->in($dir)->get());
$this->assertContainsOnlyInstancesOf('SplFileInfo', $this->file->find($pattern)->in($dir)->get());

// Test amounts returned when specified limits are given
Expand All @@ -163,24 +163,20 @@ public function testGet()
$this->assertInstanceOf('SplFileInfo', $this->file->find($pattern)->in($dir)->get(1));
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessageRegExp /^An integer of -?[\d]+ cannot be passed as a limit to the `get` method. Only -1, 1 or more can be given.$/
*/
public function testThrowsInvalidArgumentExceptionOnLessThanMinusOne()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/^An integer of -?[\d]+ cannot be passed as a limit to the `get` method. Only -1, 1 or more can be given.$/');
$pattern = '/^test[\w\d-]*.txt$/';
$dir = 'tests/files/01/02';

$this->file->find($pattern)->in($dir)->get(-2);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessageRegExp /^An integer of -?[\d]+ cannot be passed as a limit to the `get` method. Only -1, 1 or more can be given.$/
*/
public function testThrowsInvalidArgumentExceptionOnZero()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/^An integer of -?[\d]+ cannot be passed as a limit to the `get` method. Only -1, 1 or more can be given.$/');
$pattern = '/^test[\w\d-]*.txt$/';
$dir = 'tests/files/01/02';

Expand Down Expand Up @@ -219,7 +215,7 @@ public function testUp()
$pattern = '/^test[\w\d-]*.txt$/';
$dir = 'tests/files/01/02';

$this->assertInternalType('array', $this->file->find($pattern)->in($dir)->up()->get());
$this->assertIsArray($this->file->find($pattern)->in($dir)->up()->get());
$this->assertInstanceOf('Affinity4\File\File', $this->file->find($pattern)->in($dir)->up());
$this->assertContainsOnlyInstancesOf('SplFileInfo', $this->file->find($pattern)->in($dir)->up()->get());
$this->assertCount(3, $this->file->find($pattern)->in($dir)->up()->get());
Expand All @@ -237,7 +233,7 @@ public function testParent()
$pattern = '/^test[\w\d-]*.txt$/';
$dir = 'tests/files/01/02';

$this->assertInternalType('array', $this->file->find($pattern)->in($dir)->parent()->get());
$this->assertIsArray($this->file->find($pattern)->in($dir)->parent()->get());
$this->assertInstanceOf('Affinity4\File\File', $this->file->find($pattern)->in($dir)->parent());
$this->assertContainsOnlyInstancesOf('SplFileInfo', $this->file->find($pattern)->in($dir)->parent()->get());
$this->assertCount(3, $this->file->find($pattern)->in($dir)->parent()->get());
Expand All @@ -255,7 +251,7 @@ public function testParents()
$pattern = '/^test01-[\w\d]{2}.txt$/';
$dir = 'tests/files/01/02';

$this->assertInternalType('array', $this->file->find($pattern)->in($dir)->parents()->get());
$this->assertIsArray($this->file->find($pattern)->in($dir)->parents()->get());
$this->assertInstanceOf('Affinity4\File\File', $this->file->find($pattern)->in($dir)->parents());
$this->assertContainsOnlyInstancesOf('SplFileInfo', $this->file->find($pattern)->in($dir)->parents()->get());
$this->assertCount(3, $this->file->find($pattern)->in($dir)->parents()->get());
Expand All @@ -273,7 +269,7 @@ public function testInGet()
$pattern = '/^test02-[\w\d]{2}.txt$/';
$dir = 'tests/files/01/02';

$this->assertInternalType('array', $this->file->find($pattern)->in($dir)->get());
$this->assertIsArray($this->file->find($pattern)->in($dir)->get());
$this->assertInstanceOf('Affinity4\File\File', $this->file->find($pattern)->in($dir));
$this->assertContainsOnlyInstancesOf('SplFileInfo', $this->file->find($pattern)->in($dir)->get());
$this->assertCount(3, $this->file->find($pattern)->in($dir)->get());
Expand Down Expand Up @@ -312,11 +308,7 @@ public function testSetFileListUsingPatternWithRegex()
'tests/files/01/02/test02-03.txt',
];

// Fix weird bug in Ubuntu 14.04 where it shuffles the arrays somehow
sort($expected);
sort($pathnames);

$this->assertArraySubset($expected, $pathnames);
$this->assertSame([], array_diff($expected, $pathnames));
}

/**
Expand Down

0 comments on commit 829e17a

Please sign in to comment.