diff --git a/composer.json b/composer.json index 5148ff56..2529ff10 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,14 @@ "slevomat/coding-standard": "^4.5.2", "doctrine/common": "^2.7", "doctrine/orm": "^2.5", - "doctrine/collections": "^1.0" + "doctrine/collections": "^1.0", + "doctrine/mongodb-odm": "^1.2" }, "conflict": { "doctrine/common": "<2.7", "doctrine/orm": "<2.5", - "doctrine/collections": "<1.0" + "doctrine/collections": "<1.0", + "doctrine/mongodb-odm": "<1.2" }, "autoload": { "psr-4": { @@ -39,5 +41,10 @@ }, "autoload-dev": { "classmap": ["tests/"] + }, + "config": { + "platform": { + "ext-mongo": "1.6.16" + } } } diff --git a/tests/DoctrineIntegration/ODM/DocumentManagerIntegrationTest.php b/tests/DoctrineIntegration/ODM/DocumentManagerIntegrationTest.php new file mode 100644 index 00000000..f46b795b --- /dev/null +++ b/tests/DoctrineIntegration/ODM/DocumentManagerIntegrationTest.php @@ -0,0 +1,37 @@ +documentManager = $documentManager; + } + + public function findDynamicType(): void + { + $test = $this->documentManager->find(MyDocument::class, 'blah-123'); + + if ($test === null) { + throw new RuntimeException('Sorry, but no...'); + } + + $test->doSomething(); + } + + public function getReferenceDynamicType(): void + { + $test = $this->documentManager->getReference(MyDocument::class, 'blah-123'); + + if ($test === null) { + throw new RuntimeException('Sorry, but no...'); + } + + $test->doSomething(); + } + + public function getPartialReferenceDynamicType(): void + { + $test = $this->documentManager->getPartialReference(MyDocument::class, 'blah-123'); + + if ($test === null) { + throw new RuntimeException('Sorry, but no...'); + } + + $test->doSomething(); + } +} + +/** + * @Document() + */ +class MyDocument +{ + /** + * @Id(strategy="NONE", type="string") + * + * @var string + */ + private $id; + + public function doSomething(): void + { + } +} diff --git a/tests/DoctrineIntegration/ODM/data/documentManagerMergeReturn.php b/tests/DoctrineIntegration/ODM/data/documentManagerMergeReturn.php new file mode 100644 index 00000000..4a190fe1 --- /dev/null +++ b/tests/DoctrineIntegration/ODM/data/documentManagerMergeReturn.php @@ -0,0 +1,43 @@ +documentManager = $documentManager; + } + + public function merge(): void + { + $test = $this->documentManager->merge(new MyDocument()); + $test->doSomething(); + } +} + +/** + * @Document() + */ +class MyDocument +{ + /** + * @Id(strategy="NONE", type="string") + * + * @var string + */ + private $id; + + public function doSomething(): void + { + } +} diff --git a/tests/DoctrineIntegration/ODM/data/documentRepositoryDynamicReturn.php b/tests/DoctrineIntegration/ODM/data/documentRepositoryDynamicReturn.php new file mode 100644 index 00000000..590bdedc --- /dev/null +++ b/tests/DoctrineIntegration/ODM/data/documentRepositoryDynamicReturn.php @@ -0,0 +1,79 @@ +repository = $documentManager->getRepository(MyDocument::class); + } + + public function findDynamicType(): void + { + $test = $this->repository->find(1); + + if ($test === null) { + throw new RuntimeException('Sorry, but no...'); + } + + $test->doSomething(); + } + + public function findOneByDynamicType(): void + { + $test = $this->repository->findOneBy(['blah' => 'testing']); + + if ($test === null) { + throw new RuntimeException('Sorry, but no...'); + } + + $test->doSomething(); + } + + public function findAllDynamicType(): void + { + $items = $this->repository->findAll(); + + foreach ($items as $test) { + $test->doSomething(); + } + } + + public function findByDynamicType(): void + { + $items = $this->repository->findBy(['blah' => 'testing']); + + foreach ($items as $test) { + $test->doSomething(); + } + } +} + +/** + * @Document() + */ +class MyDocument +{ + /** + * @Id(strategy="NONE", type="string") + * + * @var string + */ + private $id; + + public function doSomething(): void + { + } +} diff --git a/tests/DoctrineIntegration/ODM/phpstan.neon b/tests/DoctrineIntegration/ODM/phpstan.neon new file mode 100644 index 00000000..446f214a --- /dev/null +++ b/tests/DoctrineIntegration/ODM/phpstan.neon @@ -0,0 +1,6 @@ +includes: + - ../../../extension.neon + +parameters: + doctrine: + repositoryClass: Doctrine\ODM\MongoDB\DocumentRepository