From 617f955b2702b1145dc41d37d4560ba0da812e71 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 13:22:11 -0400 Subject: [PATCH 01/14] Closes #83 - Moving to >= PHP 7.2 --- .travis.yml | 6 +- composer.json | 11 ++-- phpunit.xml.dist | 10 +++- tests/ConverterConvertSQLTest.php | 6 +- .../Console/Command/FilterCommandTest.php | 14 +++++ tests/FilterCollectionTest.php | 8 ++- tests/FilterTest.php | 10 ++-- tests/ManagerTest.php | 55 +++++++++++-------- tests/Notify/EmailTest.php | 13 +++-- tests/QueueTest.php | 41 ++++++++------ tests/ReportTest.php | 8 ++- 11 files changed, 115 insertions(+), 67 deletions(-) create mode 100644 tests/Expose/Console/Command/FilterCommandTest.php diff --git a/.travis.yml b/.travis.yml index 3d4f8cb..1a684c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ before_script: - wget http://getcomposer.org/composer.phar - php composer.phar install --dev php: - - 5.5 - - 5.6 - - 7.0 + - 7.2 + - 7.3 + - 7.4 script: phpunit diff --git a/composer.json b/composer.json index 30e1a34..83837c2 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,6 @@ { "name":"enygma/expose", + "version": "4.0.0", "type":"library", "description":"An intrusion detection library based on PHPIDS", "keywords":["ids","intrusion","detection"], @@ -13,13 +14,13 @@ } ], "require":{ - "php":">=5.3.1", - "twig/twig": "1.*|2.*", - "monolog/monolog": "~1.4", - "symfony/console": "~2.1|~3.0" + "php":">=7.2", + "twig/twig": "~3.0", + "monolog/monolog": "~2.0", + "symfony/console": "~2.1|~3.0|~4.0|~5.0" }, "require-dev" : { - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": "~7.0", "squizlabs/php_codesniffer": "1.*", "phpmd/phpmd": "dev-master" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6d3f7e0..ca36fe6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,7 @@ convertErrorsToExceptions="true" convertWarningsToExceptions="true" convertNoticesToExceptions="true" - mapTestClassNameToCoveredClassName="true" bootstrap="vendor/autoload.php" - strict="true" verbose="true" colors="true"> @@ -13,4 +11,12 @@ ./tests/ + + + src + + src/autoload.php + + + diff --git a/tests/ConverterConvertSQLTest.php b/tests/ConverterConvertSQLTest.php index 0c54780..168ecb5 100644 --- a/tests/ConverterConvertSQLTest.php +++ b/tests/ConverterConvertSQLTest.php @@ -2,7 +2,9 @@ namespace Expose\Converter; -class ConvertSQLTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class ConvertSQLTest extends TestCase { /** @@ -12,7 +14,7 @@ class ConvertSQLTest extends \PHPUnit_Framework_TestCase */ public function testConvertFromSQLKeywordsWithNull() { - $converter = new \Expose\Converter\ConvertSQL(); + $converter = new ConvertSQL(); $this->assertEquals($converter->convertFromSQLKeywords('SELECT 1,null;'), 'SELECT 1,0;'); $this->assertEquals($converter->convertFromSQLKeywords('SELECT 1, null;'), 'SELECT 1,0;'); } diff --git a/tests/Expose/Console/Command/FilterCommandTest.php b/tests/Expose/Console/Command/FilterCommandTest.php new file mode 100644 index 0000000..2d40f4c --- /dev/null +++ b/tests/Expose/Console/Command/FilterCommandTest.php @@ -0,0 +1,14 @@ +assertInstanceOf('Expose\Console\Command\FilterCommand', $tst); + } +} diff --git a/tests/FilterCollectionTest.php b/tests/FilterCollectionTest.php index 5108d95..523f168 100644 --- a/tests/FilterCollectionTest.php +++ b/tests/FilterCollectionTest.php @@ -2,7 +2,9 @@ namespace Expose; -class FilterConnectionTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class FilterConnectionTest extends TestCase { /** * @var \Expose\FilterCollection @@ -26,7 +28,7 @@ public function testGetSetFilterData() array('id' => 1234) ); - $filter = new \Expose\Filter(); + $filter = new Filter(); $filter->setId(1234); $this->collection->setFilterData($data); @@ -46,7 +48,7 @@ public function testGetFilterDataWithId() { array('id' => 1234) ); - $filter = new \Expose\Filter(); + $filter = new Filter(); $filter->setId(1234); $this->collection->setFilterData($data); diff --git a/tests/FilterTest.php b/tests/FilterTest.php index 2f7ce1f..d7f14bb 100644 --- a/tests/FilterTest.php +++ b/tests/FilterTest.php @@ -2,13 +2,15 @@ namespace Expose; -class FilterTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class FilterTest extends TestCase { private $filter = null; public function setUp() { - $this->filter = new \Expose\Filter(); + $this->filter = new Filter(); } /** @@ -140,11 +142,11 @@ public function testOutputAsArray() 'tags' => array('csrf', 'xss'), 'impact' => 3 ); - $filter = new \Expose\Filter($data); + $filter = new Filter($data); $data['tags'] = 'csrf, xss'; $this->assertEquals( $filter->toArray(), $data ); } -} \ No newline at end of file +} diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index b86f29f..fc49274 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -2,11 +2,18 @@ namespace Expose; +use Expose\Exception\QueueNotDefined; +use Expose\Log\Mongo; +use Expose\Notify\Email; +use Expose\Queue\MockQueue; +use PHPUnit\Framework\TestCase; + require_once 'MockLogger.php'; require_once 'MockQueue.php'; -class ManagerTest extends \PHPUnit_Framework_TestCase +class ManagerTest extends TestCase { + /** @var Manager */ private $manager = null; private $sampleFilters = array( array( @@ -20,18 +27,18 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $logger = new \Expose\Log\Mongo(); - $filters = new \Expose\FilterCollection(); - $this->manager = new \Expose\Manager($filters, $logger); + $logger = new Mongo(); + $filters = new FilterCollection(); + $this->manager = new Manager($filters, $logger); } public function executeFilters($data, $queue = false, $notify = false) { - $filterCollection = new \Expose\FilterCollection(); + $filterCollection = new FilterCollection(); $filterCollection->setFilterData($this->sampleFilters); $logger = new MockLogger(); - $manager = new \Expose\Manager($filterCollection, $logger); + $manager = new Manager($filterCollection, $logger); $manager->setConfig(array('test' => 'foo')); $manager->run($data, $queue, $notify); @@ -47,7 +54,7 @@ public function executeFilters($data, $queue = false, $notify = false) */ public function testGetSetFilters() { - $filters = new \Expose\FilterCollection(); + $filters = new FilterCollection(); $filters->setFilterData($this->sampleFilters); $this->manager->setFilters($filters); @@ -71,7 +78,7 @@ public function testGetSetData() $this->manager->setData($data); $getData = $this->manager->getData(); $this->assertTrue( - $getData instanceof \Expose\DataCollection + $getData instanceof DataCollection ); } @@ -127,11 +134,11 @@ public function testRunSuccessWithImpactLimit() ) ); - $filterCollection = new \Expose\FilterCollection(); + $filterCollection = new FilterCollection(); $filterCollection->setFilterData($this->sampleFilters); $logger = new MockLogger(); - $manager = new \Expose\Manager($filterCollection, $logger); + $manager = new Manager($filterCollection, $logger); $manager->setImpactLimit(1); $manager->setConfig(array('test' => 'foo')); $manager->run($data, false, false); @@ -160,7 +167,7 @@ public function testRunExportFound() $this->assertEquals(count($export), 1); $report = array_shift($export); - $this->assertTrue($report instanceof \Expose\Report); + $this->assertTrue($report instanceof Report); } /** @@ -273,11 +280,11 @@ public function testSetupConfigArray() */ public function testExceptionIsIgnored() { - $filterCollection = new \Expose\FilterCollection(); + $filterCollection = new FilterCollection(); $filterCollection->setFilterData($this->sampleFilters); $logger = new MockLogger(); - $manager = new \Expose\Manager($filterCollection, $logger); + $manager = new Manager($filterCollection, $logger); $manager->setConfig(array('test' => 'foo')); $manager->setException('POST.foo'); $manager->setException('POST.bar.baz'); @@ -303,11 +310,11 @@ public function testExceptionIsIgnored() */ public function testExceptionWildcardIsIgnored() { - $filterCollection = new \Expose\FilterCollection(); + $filterCollection = new FilterCollection(); $filterCollection->setFilterData($this->sampleFilters); $logger = new MockLogger(); - $manager = new \Expose\Manager($filterCollection, $logger); + $manager = new Manager($filterCollection, $logger); $manager->setConfig(array('test' => 'foo')); $manager->setException('POST.foo[0-9]+'); @@ -329,7 +336,7 @@ public function testExceptionWildcardIsIgnored() */ public function testGetSetQueue() { - $queue = new \Expose\Queue\MockQueue(); + $queue = new MockQueue(); $this->manager->setQueue($queue); $this->assertEquals( @@ -343,10 +350,10 @@ public function testGetSetQueue() * first gives us an exception * * @covers \Expose\Manager::getQueue - * @expectedException \Expose\Exception\QueueNotDefined */ public function testGetUndefinedQueue() { + $this->expectException(QueueNotDefined::class); $queue = $this->manager->getQueue(); } @@ -358,7 +365,7 @@ public function testGetUndefinedQueue() */ public function testGetSetNotify() { - $notify = new \Expose\Notify\Email(); + $notify = new Email(); $this->manager->setNotify($notify); $this->assertEquals( @@ -369,14 +376,14 @@ public function testGetSetNotify() public function testThresholdLowerThenImpact() { - $filter = new \Expose\Filter(); + $filter = new Filter(); $filter->setImpact(100); - $collection = new \Expose\FilterCollection(); + $collection = new FilterCollection(); $collection->addFilter($filter); $manager_mock = $this->getMockBuilder('\\Expose\\Manager') - ->setConstructorArgs(array($collection, new \Expose\MockLogger())) + ->setConstructorArgs(array($collection, new MockLogger())) ->setMethods(array('sendNotification')) ->getMock(); @@ -390,14 +397,14 @@ public function testThresholdLowerThenImpact() { } public function testThresholdHigherThenImpact() { - $filter = new \Expose\Filter(); + $filter = new Filter(); $filter->setImpact(5); - $collection = new \Expose\FilterCollection(); + $collection = new FilterCollection(); $collection->addFilter($filter); $manager_mock = $this->getMockBuilder('\\Expose\\Manager') - ->setConstructorArgs(array($collection, new \Expose\MockLogger())) + ->setConstructorArgs(array($collection, new MockLogger())) ->setMethods(array('sendNotification')) ->getMock(); diff --git a/tests/Notify/EmailTest.php b/tests/Notify/EmailTest.php index f5e5de0..5137cf6 100644 --- a/tests/Notify/EmailTest.php +++ b/tests/Notify/EmailTest.php @@ -2,13 +2,16 @@ namespace Expose\Notify; -class EmailTest extends \PHPUnit_Framework_TestCase +use InvalidArgumentException; +use PHPUnit\Framework\TestCase; + +class EmailTest extends TestCase { private $email = null; public function setUp() { - $this->email = new \Expose\Notify\Email(); + $this->email = new Email(); } /** @@ -32,7 +35,7 @@ public function testSetToAddress() * Try to set an invalid email To address * * @covers \Expose\Notify\Email::setToAddress - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ public function testSetInvalidEmailToAddress() { @@ -61,11 +64,11 @@ public function testSetFromAddress() * Try to set an invalid email From address * * @covers \Expose\Notify\Email::setFromAddress - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ public function testSetInvalidEmailFromAddress() { $email = 'invalidemail'; $this->email->setFromAddress($email); } -} \ No newline at end of file +} diff --git a/tests/QueueTest.php b/tests/QueueTest.php index 48b9313..fce9e5f 100644 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -2,41 +2,50 @@ namespace Expose; +use Expose\Queue\Mongo; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use stdClass; + include_once 'MockMongoCollection.php'; -class QueueTest extends \PHPUnit_Framework_TestCase +class QueueTest extends TestCase { private $queue = null; /** * Get a mock of the Queue object that returns the given results - * + * * @param mixed $return Return data - * @return Mocked object + * + * @return MockObject */ public function getQueueMock($return) { - $collection = new \Expose\MockMongoCollection($return); + $collection = new MockMongoCollection($return); - $mock = $this->getMock('\\Expose\\Queue\\Mongo', array('getCollection')); + $mock = $this->getMockBuilder( + '\\Expose\\Queue\\Mongo', + )->setMethods(array('getCollection')) + ->getMock(); $mock->expects($this->once()) ->method('getCollection') ->will($this->returnValue($collection)); - + return $mock; } /** * Test the setting of the adapter on object construction - * + * * @covers \Expose\Queue::__construct * @covers \Expose\Queue::getAdapter */ public function testSetAdapterOnConstruct() { - $adapter = new \stdClass(); + $adapter = new stdClass(); $adapter->foo = 'test'; - $queue = new \Expose\Queue\Mongo($adapter); + $queue = new Mongo($adapter); $this->assertEquals( $queue->getAdapter(), @@ -46,16 +55,16 @@ public function testSetAdapterOnConstruct() /** * Test the getter/setter for the adapter of the queue - * + * * @covers \Expose\Queue::getAdapter * @covers \Expose\Queue::setAdapter */ public function testGetSetAdapter() { - $adapter = new \stdClass(); + $adapter = new stdClass(); $adapter->foo = 'test'; - - $queue = new \Expose\Queue\Mongo(); + + $queue = new Mongo(); $queue->setAdapter($adapter); $this->assertEquals( @@ -66,7 +75,7 @@ public function testGetSetAdapter() /** * Get the current set of pending records - * + * * @covers \Expose\Queue::getPending */ public function testGetPendingRecords() @@ -85,7 +94,7 @@ public function testGetPendingRecords() $queue = $this->getQueueMock($result); $results = $queue->getPending(); - + // be sure they're all "pending" $pass = true; foreach ($results as $result) { @@ -96,4 +105,4 @@ public function testGetPendingRecords() $this->assertTrue($pass, 'Non-pending records found'); } -} \ No newline at end of file +} diff --git a/tests/ReportTest.php b/tests/ReportTest.php index 2b552a3..ce19f82 100644 --- a/tests/ReportTest.php +++ b/tests/ReportTest.php @@ -2,13 +2,15 @@ namespace Expose; -class ReportTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class ReportTest extends TestCase { private $report = null; public function setUp() { - $this->report = new \Expose\Report(); + $this->report = new Report(); } /** @@ -99,7 +101,7 @@ public function testObjectToArray() */ public function testObjectToArrayExpandFilters() { - $filter = new \Expose\Filter(); + $filter = new Filter(); $filter->setId(1234); $this->report->addFilterMatch($filter); From 70ca8f9bb95b274158b5ea3fd9f8e02840689065 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 13:25:43 -0400 Subject: [PATCH 02/14] Closes #83 - Moving to >= PHP 7.2 - fixing setUp() --- tests/FilterCollectionTest.php | 2 +- tests/FilterTest.php | 18 +++++++++--------- tests/ManagerTest.php | 2 +- tests/Notify/EmailTest.php | 2 +- tests/ReportTest.php | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/FilterCollectionTest.php b/tests/FilterCollectionTest.php index 523f168..0530502 100644 --- a/tests/FilterCollectionTest.php +++ b/tests/FilterCollectionTest.php @@ -11,7 +11,7 @@ class FilterConnectionTest extends TestCase */ private $collection = null; - public function setUp() + public function setUp(): void { $this->collection = new FilterCollection(); } diff --git a/tests/FilterTest.php b/tests/FilterTest.php index d7f14bb..8034701 100644 --- a/tests/FilterTest.php +++ b/tests/FilterTest.php @@ -8,14 +8,14 @@ class FilterTest extends TestCase { private $filter = null; - public function setUp() + public function setUp(): void { $this->filter = new Filter(); } /** * Test the getter/setter for impact value - * + * * @covers \Expose\Filter::setImpact * @covers \Expose\Filter::getImpact */ @@ -31,7 +31,7 @@ public function testGetSetImpact() /** * Test the getter/setter for the tag value - * + * * @covers \Expose\Filter::setTags * @covers \Expose\Filter::getTags */ @@ -47,7 +47,7 @@ public function testGetSetTags() /** * Test the getter/setter for the description - * + * * @covers \Expose\Filter::setDescription * @covers \Expose\Filter::getDescription */ @@ -63,7 +63,7 @@ public function testGetSetDescription() /** * Test the getter/setter for the ID - * + * * @covers \Expose\Filter::setId * @covers \Expose\Filter::getId */ @@ -79,7 +79,7 @@ public function testGetSetId() /** * Test the gettet/setter for the regex rule - * + * * @covers \Expose\Filter::setRule * @covers \Expose\Filter::getRule */ @@ -96,7 +96,7 @@ public function testGetSetRule() /** * Test that the result is true when a match is found * for the rule - * + * * @covers \Expose\Filter::setRule * @covers \Expose\Filter::execute */ @@ -113,7 +113,7 @@ public function testMatchDataValid() /** * Test that the result is false when a match is not found - * + * * @covers \Expose\Filter::setRule * @covers \Expose\Filter::execute */ @@ -130,7 +130,7 @@ public function testMAtchDataInvalid() /** * Test that the output of the data in an array is correct - * + * * @covers \Expose\Filter::toArray */ public function testOutputAsArray() diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index fc49274..2972433 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -25,7 +25,7 @@ class ManagerTest extends TestCase ), ); - public function setUp() + public function setUp(): void { $logger = new Mongo(); $filters = new FilterCollection(); diff --git a/tests/Notify/EmailTest.php b/tests/Notify/EmailTest.php index 5137cf6..a2c2adf 100644 --- a/tests/Notify/EmailTest.php +++ b/tests/Notify/EmailTest.php @@ -9,7 +9,7 @@ class EmailTest extends TestCase { private $email = null; - public function setUp() + public function setUp(): void { $this->email = new Email(); } diff --git a/tests/ReportTest.php b/tests/ReportTest.php index ce19f82..3d7bdce 100644 --- a/tests/ReportTest.php +++ b/tests/ReportTest.php @@ -8,7 +8,7 @@ class ReportTest extends TestCase { private $report = null; - public function setUp() + public function setUp(): void { $this->report = new Report(); } From 2eb9db2d0c91a78054b93f3494096db02edaa51c Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 13:31:49 -0400 Subject: [PATCH 03/14] Closes #83 - Moving to >= PHP 7.2 - fixing travis-ci --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a684c2..0f210ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php before_script: - phpenv config-add travis-config.ini - - wget http://getcomposer.org/composer.phar - - php composer.phar install --dev + - composer install --dev php: - 7.2 - 7.3 From a4ce2cb890ebfc7a26b0bc90721c1380bab8b567 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 13:35:24 -0400 Subject: [PATCH 04/14] Closes #83 - Moving to >= PHP 7.2 - fixing PHPUnit upgrade issues --- tests/Notify/EmailTest.php | 4 ++-- travis-config.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Notify/EmailTest.php b/tests/Notify/EmailTest.php index a2c2adf..624a6a6 100644 --- a/tests/Notify/EmailTest.php +++ b/tests/Notify/EmailTest.php @@ -35,10 +35,10 @@ public function testSetToAddress() * Try to set an invalid email To address * * @covers \Expose\Notify\Email::setToAddress - * @expectedException InvalidArgumentException */ public function testSetInvalidEmailToAddress() { + $this->expectException(InvalidArgumentException::class); $email = 'invalidemail'; $this->email->setToAddress($email); } @@ -64,10 +64,10 @@ public function testSetFromAddress() * Try to set an invalid email From address * * @covers \Expose\Notify\Email::setFromAddress - * @expectedException InvalidArgumentException */ public function testSetInvalidEmailFromAddress() { + $this->expectException(InvalidArgumentException::class); $email = 'invalidemail'; $this->email->setFromAddress($email); } diff --git a/travis-config.ini b/travis-config.ini index ea22061..adb28d5 100644 --- a/travis-config.ini +++ b/travis-config.ini @@ -1 +1 @@ -extension = "mongo.so" \ No newline at end of file +extension = "mongo" From a5957fdefbb47419ef1a2d81343b3b67d72a3271 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 13:38:59 -0400 Subject: [PATCH 05/14] Closes #83 - Moving to >= PHP 7.2 - fixing mongo not there --- .travis.yml | 1 + travis-config.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f210ea..2d97772 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: php before_script: + - pecl install mongo - phpenv config-add travis-config.ini - composer install --dev php: diff --git a/travis-config.ini b/travis-config.ini index adb28d5..30298f6 100644 --- a/travis-config.ini +++ b/travis-config.ini @@ -1 +1 @@ -extension = "mongo" +extension = "mongo.so" From 3c4ca455ed239d608ff6ab2d6abfcf23dce25e55 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 13:53:15 -0400 Subject: [PATCH 06/14] Closes #83 - Moving to >= PHP 7.2 - adding code coverage --- .travis.yml | 1 - composer.json | 3 ++- phpunit.xml.dist | 3 +++ tests/MockMongoCollection.php | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d97772..0f210ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: php before_script: - - pecl install mongo - phpenv config-add travis-config.ini - composer install --dev php: diff --git a/composer.json b/composer.json index 83837c2..2207ac4 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "require-dev" : { "phpunit/phpunit": "~7.0", "squizlabs/php_codesniffer": "1.*", - "phpmd/phpmd": "dev-master" + "phpmd/phpmd": "dev-master", + "php-coveralls/php-coveralls": "^2.2" }, "autoload": { "psr-0": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ca36fe6..075a634 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,4 +19,7 @@ + + + diff --git a/tests/MockMongoCollection.php b/tests/MockMongoCollection.php index eaff262..2c3948a 100644 --- a/tests/MockMongoCollection.php +++ b/tests/MockMongoCollection.php @@ -13,11 +13,11 @@ class MockMongoCollection public function __construct($data) { - $this->data = new \Expose\MockMongoCursor($data); + $this->data = new MockMongoCursor($data); } public function __call($name, $args) { return $this->data; } -} \ No newline at end of file +} From 2a148129e8a3ff21f782d6c5a506d4fcf43405b1 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 14:00:08 -0400 Subject: [PATCH 07/14] Closes #83 - Moving to >= PHP 7.2 - removing code coverage --- composer.json | 3 +-- phpunit.xml.dist | 3 --- tests/QueueTest.php | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2207ac4..83837c2 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,7 @@ "require-dev" : { "phpunit/phpunit": "~7.0", "squizlabs/php_codesniffer": "1.*", - "phpmd/phpmd": "dev-master", - "php-coveralls/php-coveralls": "^2.2" + "phpmd/phpmd": "dev-master" }, "autoload": { "psr-0": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 075a634..ca36fe6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,7 +19,4 @@ - - - diff --git a/tests/QueueTest.php b/tests/QueueTest.php index fce9e5f..023d85b 100644 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -25,7 +25,7 @@ public function getQueueMock($return) $collection = new MockMongoCollection($return); $mock = $this->getMockBuilder( - '\\Expose\\Queue\\Mongo', + Mongo::class )->setMethods(array('getCollection')) ->getMock(); $mock->expects($this->once()) From a0d94bbd8d81aa79c434eb6a7c55f3ada3b258a1 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 14:16:55 -0400 Subject: [PATCH 08/14] Closes #83 - Moving to >= PHP 7.2 - fixing mongodb --- .travis.yml | 1 + src/Expose/Queue/Mongo.php | 4 +++- travis-config.ini | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f210ea..66a8f29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: php before_script: + - pecl install mongodb - phpenv config-add travis-config.ini - composer install --dev php: diff --git a/src/Expose/Queue/Mongo.php b/src/Expose/Queue/Mongo.php index 7f77fc5..1ca4889 100644 --- a/src/Expose/Queue/Mongo.php +++ b/src/Expose/Queue/Mongo.php @@ -2,6 +2,8 @@ namespace Expose\Queue; +use MongoDB\Driver\Manager; + class Mongo extends \Expose\Queue { /** @@ -24,7 +26,7 @@ class Mongo extends \Expose\Queue public function getAdapter() { if ($this->adapter === null) { - $this->setAdapter(new \MongoClient()); + $this->setAdapter(new Manager()); } return $this->adapter; } diff --git a/travis-config.ini b/travis-config.ini index 30298f6..33d8975 100644 --- a/travis-config.ini +++ b/travis-config.ini @@ -1 +1 @@ -extension = "mongo.so" +extension = "mongodb.so" From e8fe89e9e676751544f9577194e7d32bd034d7ed Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 14:21:13 -0400 Subject: [PATCH 09/14] Closes #83 - Moving to >= PHP 7.2 - fixing mongodb2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 66a8f29..1b6806e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php before_script: - - pecl install mongodb + - phpenv config-add travis-config.ini - phpenv config-add travis-config.ini - composer install --dev php: From b83ad300d34afc516001190605cdb44bec26932b Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 14:27:41 -0400 Subject: [PATCH 10/14] Closes #83 - Moving to >= PHP 7.2 - fixing mongodb3 --- composer.json | 3 ++- tests/Expose/Queue/MongoTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/Expose/Queue/MongoTest.php diff --git a/composer.json b/composer.json index 83837c2..ed3eec9 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "php":">=7.2", "twig/twig": "~3.0", "monolog/monolog": "~2.0", - "symfony/console": "~2.1|~3.0|~4.0|~5.0" + "symfony/console": "~2.1|~3.0|~4.0|~5.0", + "ext-mongodb": "*" }, "require-dev" : { "phpunit/phpunit": "~7.0", diff --git a/tests/Expose/Queue/MongoTest.php b/tests/Expose/Queue/MongoTest.php new file mode 100644 index 0000000..2c72a5e --- /dev/null +++ b/tests/Expose/Queue/MongoTest.php @@ -0,0 +1,25 @@ +test = new Mongo(); + } + + public function testGetAdapter() + { + $this->assertInstanceOf(Manager::class, $this->test->getAdapter()); + } +} From 90cadc5399b79016fe55db84fc42e6f4ccd04658 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 14:32:06 -0400 Subject: [PATCH 11/14] Closes #83 - Moving to >= PHP 7.2 - fixing mongodb3 --- tests/Expose/Queue/MongoTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Expose/Queue/MongoTest.php b/tests/Expose/Queue/MongoTest.php index 2c72a5e..a067f03 100644 --- a/tests/Expose/Queue/MongoTest.php +++ b/tests/Expose/Queue/MongoTest.php @@ -13,7 +13,7 @@ class MongoTest extends TestCase */ private $test; - protected function setUp() + protected function setUp(): void { $this->test = new Mongo(); } From bd1bf51d64f56bc8012159f13469f0507c8f7e97 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 15:47:13 -0400 Subject: [PATCH 12/14] Closes #83 - Moving to >= PHP 7.2 - final? --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index ed3eec9..b9ce90d 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,10 @@ "php":">=7.2", "twig/twig": "~3.0", "monolog/monolog": "~2.0", - "symfony/console": "~2.1|~3.0|~4.0|~5.0", - "ext-mongodb": "*" + "symfony/console": "~2.1|~3.0|~4.0|~5.0" }, "require-dev" : { - "phpunit/phpunit": "~7.0", + "phpunit/phpunit": "9.*", "squizlabs/php_codesniffer": "1.*", "phpmd/phpmd": "dev-master" }, From 56e79132b72e5c8e00745f5a4ae10cbda50e6869 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 15:51:52 -0400 Subject: [PATCH 13/14] Closes #83 - Moving to >= PHP 7.2 - roll back phpunit to 7.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b9ce90d..5ecfab6 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "symfony/console": "~2.1|~3.0|~4.0|~5.0" }, "require-dev" : { - "phpunit/phpunit": "9.*", + "phpunit/phpunit": "7.*", "squizlabs/php_codesniffer": "1.*", "phpmd/phpmd": "dev-master" }, From 1017cf097505240b153c3ac039fad22b072b7342 Mon Sep 17 00:00:00 2001 From: jdcook Date: Mon, 17 Aug 2020 15:52:43 -0400 Subject: [PATCH 14/14] Closes #83 - Moving to >= PHP 7.2 - cleanup --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b6806e..eead7a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php before_script: - phpenv config-add travis-config.ini - - phpenv config-add travis-config.ini - - composer install --dev + - composer install php: - 7.2 - 7.3