Skip to content

Commit

Permalink
Merge 4cb139e into 3445266
Browse files Browse the repository at this point in the history
  • Loading branch information
codisart committed Oct 15, 2020
2 parents 3445266 + 4cb139e commit a4c9831
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 54 deletions.
26 changes: 7 additions & 19 deletions .travis.yml
Expand Up @@ -6,42 +6,30 @@ cache:

env:
global:
- COMPOSER_ARGS="--no-interaction"
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- COVERAGE_DEPS="php-coveralls/php-coveralls"

matrix:
fast_finish: true
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=latest
- php: 7.1
- php: 7.3
env:
- DEPS=lowest
- php: 7.1
- php: 7.3
env:
- DEPS=latest
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.2
- php: 7.4
env:
- DEPS=lowest
- php: 7.2
- php: 7.4
env:
- DEPS=latest
- php: 7.3
- php: nightly
env:
- DEPS=lowest
- php: 7.3
- php: nightly
env:
- DEPS=latest

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -25,7 +25,7 @@
}
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.3 || ~8.0.0",
"laminas/laminas-stdlib": "^2.7.7 || ^3.1",
"laminas/laminas-zendframework-bridge": "^1.0"
},
Expand All @@ -37,7 +37,7 @@
"laminas/laminas-servicemanager": "^2.7.8 || ^3.3",
"laminas/laminas-session": "^2.8",
"laminas/laminas-validator": "^2.10.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2"
"phpunit/phpunit": "^9.3.0"
},
"suggest": {
"laminas/laminas-filter": "Laminas\\Filter component",
Expand Down
6 changes: 4 additions & 2 deletions src/ClassFileLocator.php
Expand Up @@ -112,15 +112,17 @@ public function accept()
}
continue;
}
list($type, $content, $line) = $token;
list($type, $content) = $token;
switch ($type) {
case T_STRING:
case T_NS_SEPARATOR:
case 312: // T_NAME_FULLY_QUALIFIED
case 314: // T_NAME_QUALIFIED
$namespace .= $content;
break;
}
}
if ($saveNamespace) {
if (isset($saveNamespace) && $saveNamespace) {
$savedNamespace = $namespace;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion test/ClassFileLocatorTest.php
Expand Up @@ -35,7 +35,7 @@ public function testIterationShouldReturnOnlyPhpFiles()
{
$locator = new ClassFileLocator(__DIR__);
foreach ($locator as $file) {
$this->assertRegexp('/\.php$/', $file->getFilename());
$this->assertMatchesRegularExpression('/\.php$/', $file->getFilename());
}
}

Expand Down
38 changes: 17 additions & 21 deletions test/Transfer/Adapter/AbstractTest.php
Expand Up @@ -26,21 +26,17 @@ class AbstractTest extends TestCase
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
public function setUp(): void
{
$this->adapter = new AbstractAdapterTestMockAdapter();
}

/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
*
* @return void
*/
public function tearDown()
public function tearDown(): void
{
}

Expand Down Expand Up @@ -94,7 +90,7 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns
];
$this->adapter->addValidators($validators);
$test = $this->adapter->getValidators();
$this->assertInternalType('array', $test);
$this->assertIsArray($test);
$this->assertCount(4, $test, var_export($test, 1));
$count = array_shift($test);
$this->assertInstanceOf(Validator\File\Count::class, $count);
Expand Down Expand Up @@ -152,7 +148,7 @@ public function testAdapterShouldAllowRetrievingAllValidatorsAtOnce()
{
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$validators = $this->adapter->getValidators();
$this->assertInternalType('array', $validators);
$this->assertIsArray($validators);
$this->assertCount(4, $validators);
foreach ($validators as $validator) {
$this->assertInstanceOf(Validator\ValidatorInterface::class, $validator);
Expand Down Expand Up @@ -191,7 +187,7 @@ public function testAdapterShouldAllowRemovingAllValidatorsAtOnce()
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$this->adapter->clearValidators();
$validators = $this->adapter->getValidators();
$this->assertInternalType('array', $validators);
$this->assertIsArray($validators);
$this->assertCount(0, $validators);
}

Expand Down Expand Up @@ -220,30 +216,30 @@ public function testValidationShouldThrowExceptionForNonexistentFile()
public function testErrorMessagesShouldBeEmptyByDefault()
{
$messages = $this->adapter->getMessages();
$this->assertInternalType('array', $messages);
$this->assertIsArray($messages);
$this->assertCount(0, $messages);
}

public function testErrorMessagesShouldBePopulatedAfterInvalidTransfer()
{
$this->testValidationShouldReturnFalseForInvalidTransfer();
$messages = $this->adapter->getMessages();
$this->assertInternalType('array', $messages);
$this->assertIsArray($messages);
$this->assertNotEmpty($messages);
}

public function testErrorCodesShouldBeNullByDefault()
{
$errors = $this->adapter->getErrors();
$this->assertInternalType('array', $errors);
$this->assertIsArray($errors);
$this->assertCount(0, $errors);
}

public function testErrorCodesShouldBePopulatedAfterInvalidTransfer()
{
$this->testValidationShouldReturnFalseForInvalidTransfer();
$errors = $this->adapter->getErrors();
$this->assertInternalType('array', $errors);
$this->assertIsArray($errors);
$this->assertNotEmpty($errors);
}

Expand Down Expand Up @@ -289,7 +285,7 @@ public function testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstan
];
$this->adapter->addFilters($filters);
$test = $this->adapter->getFilters();
$this->assertInternalType('array', $test);
$this->assertIsArray($test);
$this->assertCount(3, $test, var_export($test, 1));
$count = array_shift($test);
$this->assertInstanceOf(Filter\Word\SeparatorToCamelCase::class, $count);
Expand Down Expand Up @@ -344,7 +340,7 @@ public function testAdapterShouldAllowRetrievingAllFiltersAtOnce()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$filters = $this->adapter->getFilters();
$this->assertInternalType('array', $filters);
$this->assertIsArray($filters);
$this->assertCount(3, $filters);
foreach ($filters as $filter) {
$this->assertInstanceOf(Filter\FilterInterface::class, $filter);
Expand Down Expand Up @@ -383,7 +379,7 @@ public function testAdapterShouldAllowRemovingAllFiltersAtOnce()
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$this->adapter->clearFilters();
$filters = $this->adapter->getFilters();
$this->assertInternalType('array', $filters);
$this->assertIsArray($filters);
$this->assertCount(0, $filters);
}

Expand All @@ -392,7 +388,7 @@ public function testTransferDestinationShouldBeMutable()
$directory = __DIR__;
$this->adapter->setDestination($directory);
$destinations = $this->adapter->getDestination();
$this->assertInternalType('array', $destinations);
$this->assertIsArray($destinations);
foreach ($destinations as $file => $destination) {
$this->assertEquals($directory, $destination);
}
Expand All @@ -408,7 +404,7 @@ public function testAdapterShouldAllowRetrievingDestinationsForAnArrayOfSpecifie
{
$this->adapter->setDestination(__DIR__);
$destinations = $this->adapter->getDestination(['bar', 'baz']);
$this->assertInternalType('array', $destinations);
$this->assertIsArray($destinations);
$directory = __DIR__;
foreach ($destinations as $file => $destination) {
$this->assertContains($file, ['bar', 'baz']);
Expand Down Expand Up @@ -489,7 +485,7 @@ public function testAdapterShouldAllowRetrievingAllFileNames()
. DIRECTORY_SEPARATOR . '_files';
$this->adapter->setDestination($path);
$files = $this->adapter->getFileName();
$this->assertInternalType('array', $files);
$this->assertIsArray($files);
$this->assertEquals($path . DIRECTORY_SEPARATOR . 'bar.png', $files['bar']);
}

Expand All @@ -499,7 +495,7 @@ public function testAdapterShouldAllowRetrievingAllFileNamesWithoutPath()
. DIRECTORY_SEPARATOR . '_files';
$this->adapter->setDestination($path);
$files = $this->adapter->getFileName(null, false);
$this->assertInternalType('array', $files);
$this->assertIsArray($files);
$this->assertEquals('bar.png', $files['bar']);
}

Expand Down Expand Up @@ -611,7 +607,7 @@ public function testTransferDestinationAtNonExistingElement()
$this->expectException(File\Transfer\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('not find');

$this->assertInternalType('string', $this->adapter->getDestination('reallynonexisting'));
$this->assertIsString($this->adapter->getDestination('reallynonexisting'));
}

/**
Expand Down
14 changes: 5 additions & 9 deletions test/Transfer/Adapter/HttpTest.php
Expand Up @@ -25,10 +25,8 @@ class HttpTest extends TestCase
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
public function setUp(): void
{
$_FILES = [
'txt' => [
Expand All @@ -45,17 +43,15 @@ public function setUp()
/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
*
* @return void
*/
public function tearDown()
public function tearDown(): void
{
}

public function testEmptyAdapter()
{
$files = $this->adapter->getFileName();
$this->assertContains('php0zgByO_test.txt', $files);
$this->assertStringContainsString('php0zgByO_test.txt', $files);
}

public function testAutoSetUploadValidator()
Expand Down Expand Up @@ -110,7 +106,7 @@ public function testReceiveUnknownFile()
try {
$this->assertFalse($this->adapter->receive('unknownFile'));
} catch (RuntimeException $e) {
$this->assertContains('not find', $e->getMessage());
$this->assertStringContainsString('not find', $e->getMessage());
}
}

Expand Down Expand Up @@ -333,6 +329,6 @@ public function testValidationOfPhpExtendsFormError()
$_FILES = [];
$adapter = new HttpTestMockAdapter();
$this->assertFalse($adapter->isValidParent());
$this->assertContains('exceeds', current($adapter->getMessages()));
$this->assertStringContainsString('exceeds', current($adapter->getMessages()));
}
}

0 comments on commit a4c9831

Please sign in to comment.