/**
* Customer オブジェクトを生成して返す.
*
* @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される.
* @return \Eccube\Entity\Customer
*/
public function createCustomer($email = null)
{
$faker = $this->getFaker();
$Customer = new Customer();
if (is_null($email)) {
$email = $faker->email;
}
$Status = $this->app['orm.em']->getRepository('Eccube\\Entity\\Master\\CustomerStatus')->find(CustomerStatus::ACTIVE);
$Pref = $this->app['eccube.repository.master.pref']->find(1);
$Customer->setName01($faker->lastName)->setName02($faker->firstName)->setEmail($email)->setPref($Pref)->setPassword('password')->setSalt($this->app['eccube.repository.customer']->createSalt(5))->setSecretKey($this->app['eccube.repository.customer']->getUniqueSecretKey($this->app))->setStatus($Status)->setDelFlg(Constant::DISABLED);
$Customer->setPassword($this->app['eccube.repository.customer']->encryptPassword($this->app, $Customer));
$this->app['orm.em']->persist($Customer);
$this->app['orm.em']->flush($Customer);
$CustomerAddress = new CustomerAddress();
$CustomerAddress->setCustomer($Customer)->setDelFlg(Constant::DISABLED);
$CustomerAddress->copyProperties($Customer);
$this->app['orm.em']->persist($CustomerAddress);
$this->app['orm.em']->flush($CustomerAddress);
return $Customer;
}