Code Duplication    Length = 33-34 lines in 2 locations

tests/Command/UserCommandsTest.php 2 locations

@@ 62-94 (lines=33) @@
59
    /**
60
     * @test
61
     */
62
    public function usersCanChangePassword()
63
    {
64
        $register = new RegisterUser('test', '[email protected]', '123', [new Role('ROLE_USER')]);
65
        $this->getCommandBus()->handle($register);
66
67
        $user = $this->getUserRepository()->getByUsername($register->getUsername());
68
        $beginningPwd = $user->getPassword();
69
        $command = new ChangePassword('456', $user->getId());
70
71
        $commandRepo = $this->getCommandRepository();
72
        $this->handleCommandAndAssertTraced(
73
            $this->getCommandBus(),
74
            $command,
75
            $commandRepo
76
        );
77
        $endPwd = $user->getPassword();
78
79
        $this->assertNotEquals($beginningPwd, $endPwd);
80
81
        $eventRepository = $this->getEventRepository();
82
83
        $foundEvents = $eventRepository->getByMessage(PasswordChanged::class);
84
        $this->assertCount(1, $foundEvents);
85
86
        /** @var PasswordChanged $event */
87
        $event = $foundEvents[0];
88
        $this->assertInstanceOf(PasswordChanged::class, $event);
89
        $this->assertEquals($command->getUserId(), $event->getUserId());
90
        $this->assertNotEquals($event->getOldPassword(), $event->getNewPassword());
91
92
        $foundEvent = $eventRepository->get($event->getId());
93
        $this->assertSame($event, $foundEvent);
94
    }
95
96
    /**
97
     * @test
@@ 99-132 (lines=34) @@
96
    /**
97
     * @test
98
     */
99
    public function usersCanChangeEmail()
100
    {
101
        $register = new RegisterUser('test', '[email protected]', '123', [new Role('ROLE_USER')]);
102
        $this->getCommandBus()->handle($register);
103
104
        $user = $this->getUserRepository()->getByUsername($register->getUsername());
105
        $beforeEmail = $user->getEmail();
106
        $command = new ChangeEmail('[email protected]', $user->getId());
107
108
        $commandRepo = $this->getCommandRepository();
109
        $this->handleCommandAndAssertTraced(
110
            $this->getCommandBus(),
111
            $command,
112
            $commandRepo
113
        );
114
        $afterEmail = $user->getEmail();
115
116
        $this->assertNotEquals($beforeEmail, $afterEmail);
117
        $this->assertEquals('[email protected]', $afterEmail);
118
119
        $eventRepository = $this->getEventRepository();
120
121
        $foundEvents = $eventRepository->getByMessage(EmailChanged::class);
122
        $this->assertCount(1, $foundEvents);
123
124
        /** @var EmailChanged $event */
125
        $event = $foundEvents[0];
126
        $this->assertInstanceOf(EmailChanged::class, $event);
127
        $this->assertEquals($beforeEmail, $event->getOldEmail());
128
        $this->assertEquals($afterEmail, $event->getNewEmail());
129
130
        $foundEvent = $eventRepository->get($event->getId());
131
        $this->assertSame($event, $foundEvent);
132
    }
133
134
    /**
135
     * @test