Code Duplication    Length = 25-26 lines in 2 locations

tests/Command/UserCommandsTest.php 2 locations

@@ 145-169 (lines=25) @@
142
    /**
143
     * @test
144
     */
145
    public function emailValidationCanBeRequested()
146
    {
147
        $register = new RegisterUser('test', '[email protected]', '123', [new Role('ROLE_USER')]);
148
        $this->getCommandBus()->handle($register);
149
150
        $user = $this->getUserRepository()->getByUsername($register->getUsername());
151
        $confirm = new ConfirmEmail($user->getConfirmationToken(), $user->getId());
152
        $this->getCommandBus()->handle($confirm);
153
        $this->assertTrue($user->isEmailConfirmed());
154
155
        $command = new RequestEmailValidation($user->getId());
156
157
        $this->handleCommandAndAssertTraced(
158
            $this->getCommandBus(),
159
            $command,
160
            $this->getCommandRepository()
161
        );
162
163
        $this->assertFalse($user->isEmailConfirmed());
164
165
        /** @var EmailValidationRequested $event */
166
        $event = $this->getEvent(EmailValidationRequested::class);
167
        $this->assertEquals($user->getId(), $event->getUserId());
168
        $this->assertEquals($user->getConfirmationToken(), $event->getValidationToken());
169
    }
170
171
    /**
172
     * @test
@@ 174-199 (lines=26) @@
171
    /**
172
     * @test
173
     */
174
    public function passwordResetCanBeRequested()
175
    {
176
        $register = new RegisterUser('test', '[email protected]', '123', [new Role('ROLE_USER')]);
177
        $this->getCommandBus()->handle($register);
178
179
        $user = $this->getUserRepository()->getByUsername($register->getUsername());
180
181
        $this->assertFalse($user->isPasswordResetRequested());
182
        $this->assertEmpty($user->getResettingToken());
183
184
        $command = new RequestPasswordReset($user->getId());
185
186
        $this->handleCommandAndAssertTraced(
187
            $this->getCommandBus(),
188
            $command,
189
            $this->getCommandRepository()
190
        );
191
192
        $this->assertTrue($user->isPasswordResetRequested());
193
        $this->assertNotEmpty($user->getResettingToken());
194
195
        /** @var PasswordResetRequested $event */
196
        $event = $this->getEvent(PasswordResetRequested::class);
197
        $this->assertEquals($user->getId(), $event->getUserId());
198
        $this->assertEquals($user->getResettingToken(), $event->getResetToken());
199
    }
200
201
    /**
202
     * @test