Failed Conditions
Pull Request — 4.0 (#7)
by Kiyotaka
08:39 queued 04:19
created

codeception/acceptance/EA11CustomizeCest.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.ec-cube.co.jp/
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
use Codeception\Util\Fixtures;
14
use Doctrine\ORM\EntityManagerInterface;
15
use Eccube\Entity\Customer;
16
use Eccube\Entity\Master\CustomerStatus;
17
use Eccube\Entity\Master\Pref;
18
use Eccube\Repository\CustomerRepository;
19
use Eccube\Security\Core\Encoder\PasswordEncoder;
20
21
class EA11CustomizeCest
22
{
23
    /**
24
     * @see https://github.com/EC-CUBE/ec-cube/pull/4687
25
     */
26
    public function test_username(\AcceptanceTester $I)
27
    {
28
        $Customer1 = $this->newCustomer('[email protected]');
29
        $Customer1->setLoginId('customer1');
0 ignored issues
show
The method setLoginId() does not seem to exist on object<Eccube\Entity\Customer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        $Customer2 = $this->newCustomer('[email protected]');
31
        $Customer2->setLoginId('customer2');
0 ignored issues
show
The method setLoginId() does not seem to exist on object<Eccube\Entity\Customer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
33
        /** @var EntityManagerInterface $entityManager */
34
        $entityManager = Fixtures::get('entityManager');
35
        $entityManager->persist($Customer1);
36
        $entityManager->persist($Customer2);
37
        $entityManager->flush();
38
39
        $I->loginAsMember('customer1', 'password');
40
    }
41
42
    private function newCustomer($email)
43
    {
44
        $Customer = new Customer();
45
        /** @var EntityManagerInterface $entityManager */
46
        $entityManager = Fixtures::get('entityManager');
47
        /** @var CustomerStatus $Status */
48
        $Status = $entityManager->find(CustomerStatus::class, CustomerStatus::REGULAR);
49
        /** @var Pref $Pref */
50
        $Pref = $entityManager->find(Pref::class, 1);
51
        /** @var CustomerRepository $customerRepository */
52
        $customerRepository = $entityManager->getRepository(Customer::class);
53
54
        $getService = Fixtures::get('getService');
55
        $passwordEncoder = $getService(PasswordEncoder::class);
56
        $salt = $passwordEncoder->createSalt();
57
        $password = $passwordEncoder->encodePassword('password', $salt);
58
        $Customer
59
            ->setName01('test')
60
            ->setName02('test')
61
            ->setKana01('テスト')
62
            ->setKana02('テスト')
63
            ->setEmail($email)
64
            ->setPostalcode('5300001')
65
            ->setPref($Pref)
66
            ->setAddr01('addr01')
67
            ->setAddr02('addr02')
68
            ->setPhoneNumber('0123456789')
69
            ->setPassword($password)
70
            ->setSalt($salt)
71
            ->setSecretKey($customerRepository->getUniqueSecretKey())
72
            ->setStatus($Status)
73
            ->setCreateDate(new \DateTime())
74
            ->setUpdateDate(new \DateTime());
75
76
        return $Customer;
77
    }
78
}
79