From e3289ec416f8ee39d2c027fee28713610d31e6cc Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 16 Jul 2013 10:11:06 -0700 Subject: [PATCH] Fix for PHP 5.3 where you can't use '$this' in a callback. --- tests/GeoIp2/Test/Database/ReaderTest.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/GeoIp2/Test/Database/ReaderTest.php b/tests/GeoIp2/Test/Database/ReaderTest.php index fc2d83a..3875013 100644 --- a/tests/GeoIp2/Test/Database/ReaderTest.php +++ b/tests/GeoIp2/Test/Database/ReaderTest.php @@ -9,10 +9,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase public function testDefaultLanguage() { $reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb'); + // Needed for PHP 5.3 + $that = $this; $this->checkAllMethods( - function ($method) use (&$reader) { + function ($method) use (&$that, &$reader) { $record = $reader->$method('81.2.69.160'); - $this->assertEquals('United Kingdom', $record->country->name); + $that->assertEquals('United Kingdom', $record->country->name); } ); $reader->close(); @@ -24,10 +26,11 @@ class ReaderTest extends \PHPUnit_Framework_TestCase 'maxmind-db/test-data/GeoIP2-City-Test.mmdb', array('xx', 'ru', 'pt-BR', 'es', 'en') ); + $that = $this; $this->checkAllMethods( - function ($method) use (&$reader) { + function ($method) use (&$that, &$reader) { $record = $reader->$method('81.2.69.160'); - $this->assertEquals('Великобритания', $record->country->name); + $that->assertEquals('Великобритания', $record->country->name); } ); $reader->close(); @@ -36,10 +39,11 @@ class ReaderTest extends \PHPUnit_Framework_TestCase public function testHasIpAddress() { $reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb'); + $that = $this; $this->checkAllMethods( - function ($method) use (&$reader) { + function ($method) use (&$that, &$reader) { $record = $reader->$method('81.2.69.160'); - $this->assertEquals('81.2.69.160', $record->traits->ipAddress); + $that->assertEquals('81.2.69.160', $record->traits->ipAddress); } ); $reader->close();