Skip to content

Commit

Permalink
bug #36917 [Cache] Accessing undefined constants raises an Error in p…
Browse files Browse the repository at this point in the history
…hp8 (derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

[Cache] Accessing undefined constants raises an Error in php8

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #36872
| License       | MIT
| Doc PR        | N/A

Calling `constant()` for an undefined constant will raise an `Error` on php 8. This PR adjust the Memcached tests to this new behavior.

Commits
-------

49fd0ef [Cache] Accessing undefined constants raises an Error in php8
  • Loading branch information
nicolas-grekas committed May 23, 2020
2 parents ee9aa2d + 49fd0ef commit 6e368f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Expand Up @@ -66,8 +66,14 @@ public function testOptions()
*/
public function testBadOptions($name, $value)
{
$this->expectException('ErrorException');
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
if (\PHP_VERSION_ID < 80000) {
$this->expectException('ErrorException');
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
} else {
$this->expectException('Error');
$this->expectExceptionMessage('Undefined class constant \'Memcached::');
}

MemcachedAdapter::createConnection([], [$name => $value]);
}

Expand Down
10 changes: 8 additions & 2 deletions src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php
Expand Up @@ -76,8 +76,14 @@ public function testOptions()
*/
public function testBadOptions($name, $value)
{
$this->expectException('ErrorException');
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
if (\PHP_VERSION_ID < 80000) {
$this->expectException('ErrorException');
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
} else {
$this->expectException('Error');
$this->expectExceptionMessage('Undefined class constant \'Memcached::');
}

MemcachedCache::createConnection([], [$name => $value]);
}

Expand Down

0 comments on commit 6e368f1

Please sign in to comment.