Eccube\Tests\Fixture\Generator::createNonMember PHP Method

createNonMember() public method

非会員の Customer オブジェクトを生成して返す.
public createNonMember ( string $email = null ) : Customer
$email string メールアドレス. null の場合は, ランダムなメールアドレスが生成される.
return Eccube\Entity\Customer
    public function createNonMember($email = null)
    {
        $sessionKey = 'eccube.front.shopping.nonmember';
        $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress';
        $faker = $this->getFaker();
        $Customer = new Customer();
        if (is_null($email)) {
            $email = $faker->safeEmail;
        }
        $Pref = $this->app['eccube.repository.master.pref']->find($faker->numberBetween(1, 47));
        $tel = explode('-', $faker->phoneNumber);
        $fax = explode('-', $faker->phoneNumber);
        $Customer->setName01($faker->lastName)->setName02($faker->firstName)->setKana01($faker->lastKanaName)->setKana02($faker->firstKanaName)->setCompanyName($faker->company)->setEmail($email)->setZip01($faker->postcode1())->setZip02($faker->postcode2())->setPref($Pref)->setAddr01($faker->city)->setAddr02($faker->streetAddress)->setTel01($tel[0])->setTel02($tel[1])->setTel03($tel[2])->setFax01($fax[0])->setFax02($fax[1])->setFax03($fax[2])->setDelFlg(Constant::DISABLED);
        $CustomerAddress = new CustomerAddress();
        $CustomerAddress->setCustomer($Customer)->setDelFlg(Constant::DISABLED);
        $CustomerAddress->copyProperties($Customer);
        $Customer->addCustomerAddress($CustomerAddress);
        $nonMember = array();
        $nonMember['customer'] = $Customer;
        $nonMember['pref'] = $Customer->getPref()->getId();
        $this->app['session']->set($sessionKey, $nonMember);
        $customerAddresses = array();
        $customerAddresses[] = $CustomerAddress;
        $this->app['session']->set($sessionCustomerAddressKey, serialize($customerAddresses));
        return $Customer;
    }