Code Duplication    Length = 76-76 lines in 2 locations

tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php 1 location

@@ 16-91 (lines=76) @@
13
/**
14
 * @BeforeMethods({"init"})
15
 */
16
final class MixedQueryFetchJoinArrayHydrationPerformanceBench
17
{
18
    /**
19
     * @var ArrayHydrator
20
     */
21
    private $hydrator;
22
23
    /**
24
     * @var ResultSetMapping
25
     */
26
    private $rsm;
27
28
    /**
29
     * @var HydratorMockStatement
30
     */
31
    private $stmt;
32
33
    public function init()
34
    {
35
        $resultSet = [
36
            [
37
                'u__id'          => '1',
38
                'u__status'      => 'developer',
39
                'u__username'    => 'romanb',
40
                'u__name'        => 'Roman',
41
                'sclr0'          => 'ROMANB',
42
                'p__phonenumber' => '42',
43
            ],
44
            [
45
                'u__id'          => '1',
46
                'u__status'      => 'developer',
47
                'u__username'    => 'romanb',
48
                'u__name'        => 'Roman',
49
                'sclr0'          => 'ROMANB',
50
                'p__phonenumber' => '43',
51
            ],
52
            [
53
                'u__id'          => '2',
54
                'u__status'      => 'developer',
55
                'u__username'    => 'romanb',
56
                'u__name'        => 'Roman',
57
                'sclr0'          => 'JWAGE',
58
                'p__phonenumber' => '91'
59
            ]
60
        ];
61
62
        for ($i = 4; $i < 10000; ++$i) {
63
            $resultSet[] = [
64
                'u__id'          => $i,
65
                'u__status'      => 'developer',
66
                'u__username'    => 'jwage',
67
                'u__name'        => 'Jonathan',
68
                'sclr0'          => 'JWAGE' . $i,
69
                'p__phonenumber' => '91'
70
            ];
71
        }
72
73
        $this->stmt     = new HydratorMockStatement($resultSet);
74
        $this->hydrator = new ArrayHydrator(EntityManagerFactory::getEntityManager([]));
75
        $this->rsm      = new ResultSetMapping;
76
77
        $this->rsm->addEntityResult(CmsUser::class, 'u');
78
        $this->rsm->addJoinedEntityResult(CmsPhonenumber::class, 'p', 'u', 'phonenumbers');
79
        $this->rsm->addFieldResult('u', 'u__id', 'id');
80
        $this->rsm->addFieldResult('u', 'u__status', 'status');
81
        $this->rsm->addFieldResult('u', 'u__username', 'username');
82
        $this->rsm->addFieldResult('u', 'u__name', 'name');
83
        $this->rsm->addScalarResult('sclr0', 'nameUpper');
84
        $this->rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
85
    }
86
87
    public function benchHydration()
88
    {
89
        $this->hydrator->hydrateAll($this->stmt, $this->rsm);
90
    }
91
}
92
93

tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php 1 location

@@ 17-92 (lines=76) @@
14
/**
15
 * @BeforeMethods({"init"})
16
 */
17
final class MixedQueryFetchJoinPartialObjectHydrationPerformanceBench
18
{
19
    /**
20
     * @var ObjectHydrator
21
     */
22
    private $hydrator;
23
24
    /**
25
     * @var ResultSetMapping
26
     */
27
    private $rsm;
28
29
    /**
30
     * @var HydratorMockStatement
31
     */
32
    private $stmt;
33
34
    public function init()
35
    {
36
        $resultSet = [
37
            [
38
                'u__id'          => '1',
39
                'u__status'      => 'developer',
40
                'u__username'    => 'romanb',
41
                'u__name'        => 'Roman',
42
                'sclr0'          => 'ROMANB',
43
                'p__phonenumber' => '42',
44
            ],
45
            [
46
                'u__id'          => '1',
47
                'u__status'      => 'developer',
48
                'u__username'    => 'romanb',
49
                'u__name'        => 'Roman',
50
                'sclr0'          => 'ROMANB',
51
                'p__phonenumber' => '43',
52
            ],
53
            [
54
                'u__id'          => '2',
55
                'u__status'      => 'developer',
56
                'u__username'    => 'romanb',
57
                'u__name'        => 'Roman',
58
                'sclr0'          => 'JWAGE',
59
                'p__phonenumber' => '91'
60
            ]
61
        ];
62
63
        for ($i = 4; $i < 2000; ++$i) {
64
            $resultSet[] = [
65
                'u__id'          => $i,
66
                'u__status'      => 'developer',
67
                'u__username'    => 'jwage',
68
                'u__name'        => 'Jonathan',
69
                'sclr0'          => 'JWAGE' . $i,
70
                'p__phonenumber' => '91'
71
            ];
72
        }
73
74
        $this->stmt     = new HydratorMockStatement($resultSet);
75
        $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([]));
76
        $this->rsm      = new ResultSetMapping;
77
78
        $this->rsm->addEntityResult(CmsUser::class, 'u');
79
        $this->rsm->addJoinedEntityResult(CmsPhonenumber::class, 'p', 'u', 'phonenumbers');
80
        $this->rsm->addFieldResult('u', 'u__id', 'id');
81
        $this->rsm->addFieldResult('u', 'u__status', 'status');
82
        $this->rsm->addFieldResult('u', 'u__username', 'username');
83
        $this->rsm->addFieldResult('u', 'u__name', 'name');
84
        $this->rsm->addScalarResult('sclr0', 'nameUpper');
85
        $this->rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
86
    }
87
88
    public function benchHydration()
89
    {
90
        $this->hydrator->hydrateAll($this->stmt, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
91
    }
92
}
93
94