Skip to content

Commit

Permalink
Less warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Feb 16, 2022
1 parent 2b18b6e commit 0c49028
Show file tree
Hide file tree
Showing 186 changed files with 1,268 additions and 2,545 deletions.
42 changes: 21 additions & 21 deletions tests/Zend/Acl/AclTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testRoleRegistryRemoveOneNonExistent()
$this->_acl->removeRole('nonexistent');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon removing a non-existent Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
}

Expand All @@ -112,7 +112,7 @@ public function testRoleRegistryAddInheritsNonExistent()
$this->_acl->addRole(new Zend_Acl_Role('guest'), 'nonexistent');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('does not exist', $e->getMessage());
$this->assertStringContainsString('does not exist', $e->getMessage());
}
}

Expand All @@ -128,14 +128,14 @@ public function testRoleRegistryInheritsNonExistent()
$this->_acl->inheritsRole('nonexistent', $roleGuest);
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent child Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}

try {
$this->_acl->inheritsRole($roleGuest, 'nonexistent');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
}

Expand Down Expand Up @@ -210,7 +210,7 @@ public function testRoleRegistryDuplicate()
->add($roleGuest);
$this->fail('Expected exception not thrown upon adding same Role twice');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('already exists', $e->getMessage());
$this->assertStringContainsString('already exists', $e->getMessage());
}
}

Expand All @@ -228,7 +228,7 @@ public function testRoleRegistryDuplicateId()
->add($roleGuest2);
$this->fail('Expected exception not thrown upon adding two Roles with same ID');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('already exists', $e->getMessage());
$this->assertStringContainsString('already exists', $e->getMessage());
}
}

Expand Down Expand Up @@ -291,7 +291,7 @@ public function testResourceRemoveOneNonExistent()
$this->_acl->remove('nonexistent');
$this->fail('Expected Zend_Acl_Exception not thrown upon removing a non-existent Resource');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
}

Expand All @@ -315,7 +315,7 @@ public function testResourceAddInheritsNonExistent()
$this->_acl->add(new Zend_Acl_Resource('area'), 'nonexistent');
$this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent parent');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('does not exist', $e->getMessage());
$this->assertStringContainsString('does not exist', $e->getMessage());
}
}

Expand All @@ -331,14 +331,14 @@ public function testResourceInheritsNonExistent()
$this->_acl->inherits('nonexistent', $resourceArea);
$this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent child Resource');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}

try {
$this->_acl->inherits($resourceArea, 'nonexistent');
$this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent parent Resource');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
}

Expand Down Expand Up @@ -374,7 +374,7 @@ public function testResourceDuplicate()
->add($resourceArea);
$this->fail('Expected exception not thrown upon adding same Resource twice');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('already exists', $e->getMessage());
$this->assertStringContainsString('already exists', $e->getMessage());
}
}

Expand All @@ -390,7 +390,7 @@ public function testResourceDuplicateId()
->add($resourceArea2);
$this->fail('Expected exception not thrown upon adding two Resources with same ID');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('already exists', $e->getMessage());
$this->assertStringContainsString('already exists', $e->getMessage());
}
}

Expand All @@ -403,14 +403,14 @@ public function testIsAllowedNonExistent()
$this->_acl->isAllowed('nonexistent');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon non-existent Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}

try {
$this->_acl->isAllowed(null, 'nonexistent');
$this->fail('Expected Zend_Acl_Exception not thrown upon non-existent Resource');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
}

Expand Down Expand Up @@ -719,7 +719,7 @@ public function testRuleRoleRemove()
$this->_acl->isAllowed('guest');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon isAllowed() on non-existent Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
$this->_acl->addRole(new Zend_Acl_Role('guest'));
$this->assertFalse($this->_acl->isAllowed('guest'));
Expand All @@ -739,7 +739,7 @@ public function testRuleRoleRemoveAll()
$this->_acl->isAllowed('guest');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon isAllowed() on non-existent Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
$this->_acl->addRole(new Zend_Acl_Role('guest'));
$this->assertFalse($this->_acl->isAllowed('guest'));
Expand All @@ -759,7 +759,7 @@ public function testRulesResourceRemove()
$this->_acl->isAllowed(null, 'area');
$this->fail('Expected Zend_Acl_Exception not thrown upon isAllowed() on non-existent Resource');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
$this->_acl->add(new Zend_Acl_Resource('area'));
$this->assertFalse($this->_acl->isAllowed(null, 'area'));
Expand All @@ -779,7 +779,7 @@ public function testRulesResourceRemoveAll()
$this->_acl->isAllowed(null, 'area');
$this->fail('Expected Zend_Acl_Exception not thrown upon isAllowed() on non-existent Resource');
} catch (Zend_Acl_Exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
}
$this->_acl->add(new Zend_Acl_Resource('area'));
$this->assertFalse($this->_acl->isAllowed(null, 'area'));
Expand Down Expand Up @@ -1076,11 +1076,11 @@ protected function _loadUseCase1()
/**
* Returns an array of registered roles.
*
* @expectedException \PHPUnit\Framework\Exception
* @group ZF-5638
*/
public function testGetRegisteredRoles()
{
$this->expectException(\PHPUnit\Framework\Exception::class);
$acl = $this->_acl;
$acl->addRole('developer');

Expand Down Expand Up @@ -1165,13 +1165,13 @@ public function testGetRegisteredRolesIsDeprecated()
try {
$this->_acl->getRegisteredRoles();
$this->fail('getRegisteredRoles() did not throw an exception');
} catch (\PHPUnit\Framework\Exception $e) {
} catch (\PHPUnit\Framework\Exception) {
self::assertTrue(true);

return;
}

$this->fail('An expected notice has not been raised');
static::fail('An expected notice has not been raised');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Zend/AllTests/StreamWrapper/PhpInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function stream_eof()
return self::$_returnValues[__FUNCTION__];
}

return 0 == strlen(self::$_data);
return 0 == strlen((string) self::$_data);
}

public function stream_read($count)
Expand All @@ -117,7 +117,7 @@ public function stream_read($count)

// To match the behavior of php://input, we need to clear out the data
// as it is read
if ($count > strlen(self::$_data)) {
if ($count > strlen((string) self::$_data)) {
$data = self::$_data;
self::$_data = '';
} else {
Expand Down
28 changes: 8 additions & 20 deletions tests/Zend/Application/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Zend_Application_ApplicationTest extends \PHPUnit\Framework\TestCase
public static function main()
{
$suite = new \PHPUnit\Framework\TestSuite(self::class);
$result = \PHPUnit\TextUI\TestRunner::run($suite);
$result = (new \PHPUnit\TextUI\TestRunner())->run($suite);
}

public function setUp(): void
Expand Down Expand Up @@ -175,7 +175,7 @@ public function testPassingIncludePathOptionShouldModifyIncludePath()
),
));
$test = get_include_path();
$this->assertContains($expected, $test);
$this->assertStringContainsString($expected, $test);
}

public function testPassingPhpSettingsSetsIniValues()
Expand Down Expand Up @@ -244,11 +244,9 @@ public function testPassingArrayBootstrapOptionShouldRegisterBootstrapBasedOnPat
$this->assertTrue($bootstrap instanceof ZfAppBootstrap);
}

/**
* @expectedException Zend_Application_Exception
*/
public function testPassingArrayBootstrapWithoutPathOptionShouldRaiseException()
{
$this->expectException(\Zend_Application_Exception::class);
$this->application->setOptions(array(
'bootstrap' => array(
'class' => 'ZfAppBootstrap',
Expand All @@ -257,22 +255,18 @@ public function testPassingArrayBootstrapWithoutPathOptionShouldRaiseException()
$bootstrap = $this->application->getBootstrap();
}

/**
* @expectedException Zend_Application_Exception
*/
public function testPassingInvalidBootstrapOptionShouldRaiseException()
{
$this->expectException(\Zend_Application_Exception::class);
$this->application->setOptions(array(
'bootstrap' => new stdClass(),
));
$bootstrap = $this->application->getBootstrap();
}

/**
* @expectedException Zend_Application_Exception
*/
public function testPassingInvalidOptionsArgumentToConstructorShouldRaiseException()
{
$this->expectException(\Zend_Application_Exception::class);
$application = new Zend_Application('testing', new stdClass());
}

Expand Down Expand Up @@ -331,11 +325,9 @@ public function testPassingArrayOptionsWithConfigKeyShouldLoadOptionsAndNotOverr
$this->assertNotEquals('bar', $application->getOption('foo'));
}

/**
* @expectedException Zend_Application_Exception
*/
public function testPassingInvalidStringOptionToConstructorShouldRaiseException()
{
$this->expectException(\Zend_Application_Exception::class);
$application = new Zend_Application('testing', __DIR__ . '/_files/appconfig');
}

Expand All @@ -359,11 +351,9 @@ public function testBootstrapImplementsFluentInterface()
$this->assertSame($application, $this->application);
}

/**
* @expectedException Zend_Application_Exception
*/
public function testApplicationShouldRaiseExceptionIfBootstrapFileDoesNotContainBootstrapClass()
{
$this->expectException(\Zend_Application_Exception::class);
$this->application->setOptions(array(
'bootstrap' => array(
'path' => __DIR__ . '/_files/ZfAppNoBootstrap.php',
Expand All @@ -373,11 +363,9 @@ public function testApplicationShouldRaiseExceptionIfBootstrapFileDoesNotContain
$bootstrap = $this->application->getBootstrap();
}

/**
* @expectedException Zend_Application_Exception
*/
public function testApplicationShouldRaiseExceptionWhenBootstrapClassNotOfCorrectType()
{
$this->expectException(\Zend_Application_Exception::class);
$this->application->setOptions(array(
'bootstrap' => array(
'path' => __DIR__ . '/_files/ZfAppBadBootstrap.php',
Expand Down
Loading

0 comments on commit 0c49028

Please sign in to comment.