Code Duplication    Length = 40-40 lines in 2 locations

src/Tests/Integration/Admin/Verification/SuccessfulVerificationTest.php 1 location

@@ 29-68 (lines=40) @@
26
use Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\Traits\AdminUserLoader;
27
use Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\Traits\ConfigurationLoader;
28
29
class SuccessfulVerificationTest extends AbstractTestClass
30
{
31
    use AdminUserLoader;
32
    use ConfigurationLoader;
33
34
    public static function getAdminUserDataPath()
35
    {
36
        return __DIR__ . '/../_files/adminUser.php';
37
    }
38
39
    public static function getConfigurationDataPath()
40
    {
41
        return __DIR__.'/../_files/two_factor_enabled.php';
42
    }
43
44
    /**
45
     * @magentoDbIsolation enabled
46
     * @magentoDataFixture loadAdminUsers
47
     * @magentoDataFixture loadConfiguration
48
     */
49
    public function testVerificationPasses()
50
    {
51
        $this->loginAdmin('two_factor_enabled');
52
        $this->getRequest()
53
            ->setMethod('POST')
54
            ->setParam('secret', $this->getValidCode('WSQO22WRQ4MRQG2SW3YTSVCLCGKCPSWG'));
55
        $this->dispatch('/backend/twofactor/adminlogin/verify');
56
57
        $this->assertRedirect($this->stringContains('admin/dashboard/index'));
58
    }
59
60
    private function getValidCode($secret)
61
    {
62
        /** @var QRCode $codeGenerator */
63
        $codeGenerator = $this->createObject(QRCode::class);
64
        $validCode = $codeGenerator->displayCurrentCode($secret);
65
66
        return $validCode;
67
    }
68
}
69

src/Tests/Integration/Customer/Verification/SuccessfulVerificationTest.php 1 location

@@ 29-68 (lines=40) @@
26
use Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\Traits\ConfigurationLoader;
27
use Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\Traits\CustomerLoader;
28
29
class SuccessfulVerificationTest extends AbstractTestClass
30
{
31
    use CustomerLoader;
32
    use ConfigurationLoader;
33
34
    public static function getCustomerDataPath()
35
    {
36
        return __DIR__.'/../_files/customer.php';
37
    }
38
39
    public static function getConfigurationDataPath()
40
    {
41
        return __DIR__.'/../_files/two_factor_enabled.php';
42
    }
43
44
    /**
45
     * @magentoDbIsolation   enabled
46
     * @magentoDataFixture   loadCustomer
47
     * @magentoDataFixture   loadConfiguration
48
     */
49
    public function testVerificationPasses()
50
    {
51
        $this->login('[email protected]');
52
        $this->getRequest()
53
            ->setMethod('POST')
54
            ->setParam('secret', $this->getValidCode('WSQO22WRQ4MRQG2SW3YTSVCLCGKCPSWG'));
55
        $this->dispatch('/twofactor/customerlogin/verify');
56
57
        $this->assertRedirect($this->stringContains('customer/account'));
58
    }
59
60
    private function getValidCode($secret)
61
    {
62
        /** @var QRCode $codeGenerator */
63
        $codeGenerator = $this->createObject(QRCode::class);
64
        $validCode = $codeGenerator->displayCurrentCode($secret);
65
66
        return $validCode;
67
    }
68
}
69