-
-
Notifications
You must be signed in to change notification settings - Fork 505
/
Copy pathGH2157Test.php
60 lines (51 loc) · 1.67 KB
/
GH2157Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Doctrine\ODM\ODM\Tests\Functional\Ticket;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;
class GH2157Test extends BaseTestCase
{
public function testFacetDiscriminatorMapCreation(): void
{
$this->dm->persist(new GH2157FirstType());
$this->dm->persist(new GH2157FirstType());
$this->dm->persist(new GH2157FirstType());
$this->dm->persist(new GH2157FirstType());
$this->dm->flush();
$result = $this->dm->createAggregationBuilder(GH2157FirstType::class)
->project()
->includeFields(['id'])
->facet()
->field('count')
->pipeline(
$this->dm->createAggregationBuilder(GH2157FirstType::class)
->count('count'),
)
->field('limitedResults')
->pipeline(
$this->dm->createAggregationBuilder(GH2157FirstType::class)
->limit(2),
)
->execute()->toArray();
self::assertEquals(4, $result[0]['count'][0]['count']);
self::assertCount(2, $result[0]['limitedResults']);
}
}
#[ODM\Document(collection: 'documents')]
#[ODM\InheritanceType('SINGLE_COLLECTION')]
#[ODM\DiscriminatorField('type')]
#[ODM\DiscriminatorMap(['firsttype' => GH2157FirstType::class, 'secondtype' => GH2157SecondType::class])]
abstract class GH2157Abstract
{
/** @var string */
#[ODM\Id]
protected $id;
}
#[ODM\Document]
class GH2157FirstType extends GH2157Abstract
{
}
#[ODM\Document]
class GH2157SecondType extends GH2157Abstract
{
}