File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 44
55use Doctrine \ODM \MongoDB \Mapping \Annotations as ODM ;
66use Doctrine \ODM \MongoDB \Tests \BaseTest ;
7+ use MongoResultException ;
78
89class GH1344Test extends BaseTest
910{
@@ -18,6 +19,16 @@ public function testGeneratingIndexesDoesNotThrowException()
1819
1920 $ this ->dm ->getSchemaManager ()->ensureDocumentIndexes (GH1344Main::class);
2021 }
22+
23+ public function testGeneratingIndexesWithTooLongIndexNameThrowsException ()
24+ {
25+ // Ensure that at least the beginning of the index name is contained in
26+ // the exception message. This can vary between driver/server versions.
27+ $ this ->expectException (MongoResultException::class);
28+ $ this ->expectExceptionMessageRegExp ('#GH1344TooLongIndexName.\$embedded1_this_is_a_really_long_name_that# ' );
29+
30+ $ this ->dm ->getSchemaManager ()->ensureDocumentIndexes (GH1344TooLongIndexName::class);
31+ }
2132}
2233
2334/** @ODM\Document */
@@ -55,3 +66,23 @@ class GH1344EmbeddedNested
5566 /** @ODM\Field */
5667 public $ property ;
5768}
69+
70+ /** @ODM\Document */
71+ class GH1344TooLongIndexName
72+ {
73+ /** @ODM\Id */
74+ public $ id ;
75+
76+ /** @ODM\EmbedOne(targetDocument=GH1344TooLongIndexNameEmbedded::class) */
77+ public $ embedded1 ;
78+ }
79+
80+ /**
81+ * @ODM\EmbeddedDocument
82+ * @ODM\Index(keys={"property"="asc"}, name="this_is_a_really_long_name_that_will_cause_problems_for_whoever_tries_to_use_it_whether_in_an_embedded_field_or_not")
83+ */
84+ class GH1344TooLongIndexNameEmbedded
85+ {
86+ /** @ODM\Field */
87+ public $ property ;
88+ }
You can’t perform that action at this time.
0 commit comments