diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a96bb714..e08fb987 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,9 +30,6 @@ jobs: - php: 7.4 mongo-ext: 1.6.0 mongo-img: 4.2 - - php: 7.4 - mongo-ext: 1.9.0 - mongo-img: 4.4 - php: 8.1 mongo-ext: 1.12.0 mongo-img: 5.0 diff --git a/Makefile b/Makefile index 51988289..7eeeb5cb 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ setup-82: | build-82 --setup-common .PHONY: sh stop sh: docker-compose.yml $(DOCKER_COMPOSE) up -d --force-recreate - $(DOCKER_COMPOSE) exec -ti php bash + $(DOCKER_COMPOSE) exec php bash stop: docker-compose.yml $(DOCKER_COMPOSE) stop @@ -82,3 +82,9 @@ cs-fix: composer cs-fix cs-check: composer cs-check + +.PHONY: rector rector-apply +rector: + bin/rector process --dry-run +rector-apply: + bin/rector process diff --git a/composer.json b/composer.json index 0f365601..ea225825 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,9 @@ "phpstan/phpstan": "1.10.41", "phpstan/extension-installer": "1.3.1", "jangregor/phpstan-prophecy": "1.0.0", - "phpspec/prophecy": "^1.17" + "phpspec/prophecy": "^1.17", + "rector/rector": "^0.18.6", + "phpspec/prophecy-phpunit": "^2.0" }, "minimum-stability": "stable", "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 75816ecc..0445e193 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,31 +1,23 @@ - - - - - - - - - - ./tests/ - - - - - - ./src/ - - ./src/Resources - ./tests - ./docs - ./vendor - - - + + + + ./src/ + + + ./src/Resources + ./tests + ./docs + ./vendor + + + + + + + + + ./tests/ + + diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..6da0e7d8 --- /dev/null +++ b/rector.php @@ -0,0 +1,22 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + + // register a single rule + $rectorConfig->rule(\Rector\PHPUnit\PHPUnit100\Rector\Class_\AddProphecyTraitRector::class); + + $rectorConfig->sets([ + PHPUnitSetList::PHPUNIT_90, + ]); +}; diff --git a/tests/Functional/Capsule/CollectionTest.php b/tests/Functional/Capsule/CollectionTest.php index c16c39ef..0211e8b2 100644 --- a/tests/Functional/Capsule/CollectionTest.php +++ b/tests/Functional/Capsule/CollectionTest.php @@ -14,6 +14,8 @@ class CollectionTest extends AppTestCase { + use \Prophecy\PhpUnit\ProphecyTrait; + private function getManager(): Manager { /** @var \Facile\MongoDbBundle\Services\ClientRegistry $reg */ diff --git a/tests/Functional/Controller/ProfilerControllerTest.php b/tests/Functional/Controller/ProfilerControllerTest.php index a7d120d5..230cdc3f 100644 --- a/tests/Functional/Controller/ProfilerControllerTest.php +++ b/tests/Functional/Controller/ProfilerControllerTest.php @@ -16,6 +16,8 @@ class ProfilerControllerTest extends AppTestCase { + use \Prophecy\PhpUnit\ProphecyTrait; + protected function setUp(): void { $this->setEnvDev(); diff --git a/tests/Unit/Capsule/ClientTest.php b/tests/Unit/Capsule/ClientTest.php index 561aa7a4..44596561 100644 --- a/tests/Unit/Capsule/ClientTest.php +++ b/tests/Unit/Capsule/ClientTest.php @@ -11,6 +11,8 @@ class ClientTest extends TestCase { + use \Prophecy\PhpUnit\ProphecyTrait; + public function test_mongodb_client_encapsulation() { $client = new Client('mongodb://localhost:27017', [], [], 'test_client', $this->prophesize(EventDispatcherInterface::class)->reveal()); diff --git a/tests/Unit/Capsule/DatabaseTest.php b/tests/Unit/Capsule/DatabaseTest.php index 0df6407d..a7268590 100644 --- a/tests/Unit/Capsule/DatabaseTest.php +++ b/tests/Unit/Capsule/DatabaseTest.php @@ -13,6 +13,8 @@ class DatabaseTest extends TestCase { + use \Prophecy\PhpUnit\ProphecyTrait; + public function test_selectCollection(): void { $manager = new Manager('mongodb://localhost'); diff --git a/tests/Unit/DataCollector/MongoQuerySerializerTest.php b/tests/Unit/DataCollector/MongoQuerySerializerTest.php index e0cfeb94..fad285d7 100644 --- a/tests/Unit/DataCollector/MongoQuerySerializerTest.php +++ b/tests/Unit/DataCollector/MongoQuerySerializerTest.php @@ -12,6 +12,8 @@ class MongoQuerySerializerTest extends TestCase { + use \Prophecy\PhpUnit\ProphecyTrait; + /** * @param $unserializedData * diff --git a/tests/Unit/Services/ClientRegistryTest.php b/tests/Unit/Services/ClientRegistryTest.php index af926cb1..2a4296d5 100644 --- a/tests/Unit/Services/ClientRegistryTest.php +++ b/tests/Unit/Services/ClientRegistryTest.php @@ -13,6 +13,8 @@ class ClientRegistryTest extends TestCase { + use \Prophecy\PhpUnit\ProphecyTrait; + public function test_client_connection_url_provided_manually() { $registry = new ClientRegistry($this->createEventDispatcherMock(), false, null);