public function createTestFixtures() { $env = $this->container->getParameter("kernel.environment"); if ($env == 'test') { $this->runSqlScript('Country.sql'); $this->runSqlScript('State.sql'); $this->runSqlScript('PostalCode.sql'); $this->runSqlScript('Role.sql'); $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder(new Actor()); //User admin $password = '******'; $user = new Actor(); $user->setUsername('admin'); $user->setEmail('*****@*****.**'); $user->addRole($this->getManager()->getRepository('CoreBundle:Role')->findOneByRole(Role::ADMIN)); $encodePassword = $encoder->encodePassword($password, $user->getSalt()); $user->setPassword($encodePassword); $user->setName('Admin 1'); $user->setSurnames('Surnames Admin'); $user->setNewsletter(true); $this->getManager()->persist($user); $this->getManager()->flush(); } }
public function load($line, $lineNo) { // print_r($line);die(); if ($lineNo != 1) { $email = trim($line[0]); $names = trim($line[1]); $postalCode = trim($line[2]); //names if (count(explode(' ', $names)) > 1) { if (count($arr = explode(' ', $names)) == 2) { $firstname = $arr[0]; $lastname = $arr[1]; } elseif (count($arr = explode(' ', $names)) == 3) { $firstname = $arr[0]; $lastname = $arr[1] . ' ' . $arr[2]; } elseif (count($arr = explode(' ', $names)) == 4) { $firstname = $arr[0] . ' ' . $arr[1]; $lastname = $arr[2] . ' ' . $arr[3]; } } else { $firstname = $names; $lastname = ''; } $actor = $this->manager->getRepository('CoreBundle:Actor')->findOneByEmail($email); if (!$actor instanceof Actor) { $optic = $this->manager->getRepository('CoreBundle:Optic')->findOneByEmail($email); if (!$optic instanceof Optic) { //create new user $this->output->writeln('<error>Actor or Optic ' . $email . ' does not exist, proced to created(actor) and swith on newsletter notification.</error>'); $actor = new Actor(); $actor->setUsername($email); $actor->setEmail($email); $actor->setPassword($email); $actor->setName($firstname); $actor->setSurnames($lastname); $actor->setIsActive(true); $actor->setNewsletter(true); try { $this->manager->persist($actor); $this->manager->flush(); } catch (\Exception $ex) { $this->output->writeln('<error>' . $ex->getMessage() . '</error>'); } } else { //active newsletter $this->output->writeln('<comment>Optic ' . $email . ' already exist and have been swith on newsletter notification .</comment>'); $optic->setNewsletter(true); $this->manager->flush(); } } else { //active newsletter $this->output->writeln('<comment>Actor ' . $email . ' already exist and have been swith on newsletter notification .</comment>'); $actor->setNewsletter(true); $this->manager->flush(); } } }
/** * Send an email to a user to confirm the subscription * * @param UserInterface $user * * @return void */ public function sendSubscribeToNewsletterMessage(Actor $user) { $templateName = 'CoreBundle:Email:subscription.email.html.twig'; $context = array('user' => $user); $this->sendMessage($templateName, $context, $this->parameters['company']['email'], $user->getEmail()); }
/** * @code * phpunit -v --filter testCreatePlan -c app vendor/sebardo/ecommerce/EcommerceBundle/Tests/Entity/PlanTest.php * @endcode * */ public function testCreatePlan() { $client = static::createClient(); $plan = new Plan(); $plan->setName('Trial Plan ' . uniqid()); $plan->setDescription('Monthly plan for getting something.'); $plan->setFrequency('MONTH'); $plan->setFrequencyInterval('1'); $plan->setCycles('11'); $plan->setAmount('19.99'); $plan->setTrialFrequency('MONTH'); $plan->setTrialFrequencyInterval('1'); $plan->setTrialCycles('1'); $plan->setTrialAmount('0'); //error $errors = $client->getContainer()->get('validator')->validate($plan); $this->assertEquals(count($errors), 0); //create $checkoutManager = $client->getContainer()->get('checkout_manager'); $payPalPlan = $checkoutManager->createPaypalPlan($plan); $this->assertEquals($payPalPlan['state'], 'CREATED'); //active and get $payPalPlan = $checkoutManager->activePaypalPlan($plan); $this->assertEquals($payPalPlan['state'], 'ACTIVE'); //create test actor $em = $client->getContainer()->get('doctrine')->getManager(); $actor = new Actor(); $uid = uniqid(); $actor->setEmail('username' . $uid); $actor->setUsername('username' . $uid . '@email.com'); $actor->setName('Test actor ' . $uid); $actor->setCity('City test'); $actor->setAddress('Address 123.'); $country = $em->getRepository('CoreBundle:Country')->find('es'); $actor->setCountry($country); //crypt password $factory = $client->getContainer()->get('security.encoder_factory'); $encoder = $factory->getEncoder(new Actor()); $encodePassword = $encoder->encodePassword($uid, $actor->getSalt()); $actor->setPassword($encodePassword); $em->persist($actor); //contract $contract = new Contract(); $contract->setFinished(new DateTime('+1 year')); $contract->setActor($actor); $contract->setUrl('http://localhost/aviso-legal'); $actor->addContract($contract); $em->persist($contract); $agree = new Agreement(); $agree->setPlan($plan); $agree->setStatus('Created'); $agree->setName('Test agreement ' . uniqid()); $agree->setDescription('Description of test agreement.'); $agree->setPaymentMethod('credit_card'); $agree->setContract($contract); $contract->setAgreement($agree); $em->persist($agree); $em->flush(); //error $errors = $client->getContainer()->get('validator')->validate($agree); $this->assertEquals(count($errors), 0); //agreement $payPalAgreement = $checkoutManager->createPaypalAgreement($agree, array("number" => "4548812049400004", "type" => "visa", "expire_month" => 12, "expire_year" => 2017, "cvv2" => 123, "first_name" => "Betsy", "last_name" => "Buyer")); // print_r($payPalAgreement); $this->assertEquals($payPalAgreement['state'], 'Active'); }
/** * Find all rows filtered for DataTables * * @param string $search The search string * @param int $sortColumn The column to sort by * @param string $sortDirection The direction to sort the column * @param entity $actor The actor relation * * @return \Doctrine\ORM\Query */ public function findAllForDataTablesByActor($search, $sortColumn, $sortDirection, Actor $actor) { // select $qb = $this->getQueryBuilder(false)->select('p.id, p.name, c.id categoryId, c.name categoryName, b.id brandId, b.name brandName, p.price, p.stock, p.active, p.available, p.highlighted, p.freeTransport, actor.id actorId, actor.name actorName'); // join $qb->join('p.category', 'c')->join('p.brand', 'b')->join('p.actor', 'actor'); $qb->where('actor.id = :actor')->setParameter('actor', $actor->getId()); // search if (!empty($search)) { $qb->andWhere('p.name LIKE :search OR c.name LIKE :search OR b.name LIKE :search OR actor.name LIKE :search')->setParameter('search', '%' . $search . '%'); } // sort by column switch ($sortColumn) { case 0: $qb->orderBy('actor.name', $sortDirection); break; case 1: $qb->orderBy('p.name', $sortDirection); break; case 3: $qb->orderBy('c.name', $sortDirection); break; case 4: $qb->orderBy('b.name', $sortDirection); break; case 5: $qb->orderBy('p.price', $sortDirection); break; case 7: $qb->orderBy('p.stock', $sortDirection); break; case 8: $qb->orderBy('p.active', $sortDirection); break; case 9: $qb->orderBy('p.available', $sortDirection); break; case 10: $qb->orderBy('p.highlighted', $sortDirection); break; case 11: $qb->orderBy('p.freeTransport', $sortDirection); break; } return $qb->getQuery(); }
/** * Creates a form to delete a Actor entity. * * @param Actor $actor The Actor entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Actor $actor) { return $this->createFormBuilder()->setAction($this->generateUrl('core_actor_delete', array('id' => $actor->getId())))->setMethod('DELETE')->getForm(); }
public function createFixtures() { $core = $this->container->getParameter('core'); $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder(new Actor()); $this->runSqlScript('Country.sql'); $this->runSqlScript('State.sql'); $this->runSqlScript('PostalCode.sql'); //Roles $userRole = new Role(); $userRole->setName('user'); $userRole->setRole(Role::USER); $this->getManager()->persist($userRole); $companyRole = new Role(); $companyRole->setName('company'); $companyRole->setRole(Role::COMPANY); $this->getManager()->persist($companyRole); $adminRole = new Role(); $adminRole->setName('admin'); $adminRole->setRole(Role::ADMIN); $this->getManager()->persist($adminRole); $superRole = new Role(); $superRole->setName('root'); $superRole->setRole(Role::SUPER_ADMIN); $this->getManager()->persist($superRole); $this->getManager()->flush(); //User admin $password = '******'; $admin = new Actor(); $admin->setUsername('admin'); $admin->setEmail('*****@*****.**'); $admin->addRole($adminRole); $encodePassword = $encoder->encodePassword($password, $admin->getSalt()); $admin->setPassword($encodePassword); $admin->setName('Admin'); $admin->setSurnames('Lastname'); $this->getManager()->persist($admin); $password = '******'; $user = new Actor(); $user->setUsername('user'); $user->setEmail('*****@*****.**'); $user->addRole($userRole); $encodePassword = $encoder->encodePassword($password, $user->getSalt()); $user->setPassword($encodePassword); $user->setName('User'); $user->setSurnames('Lastname'); $this->getManager()->persist($user); $password2 = 'user2'; $user2 = new Actor(); $user2->setUsername('user2'); $user2->setEmail('*****@*****.**'); $user2->addRole($userRole); $encodePassword2 = $encoder->encodePassword($password2, $user2->getSalt()); $user2->setPassword($encodePassword2); $user2->setName('User2'); $user2->setSurnames('Lastname2'); $this->getManager()->persist($user2); $this->getManager()->flush(); //copy profile imges //self::recurseCopy(__DIR__.'/images', __DIR__.'/../../../../../../web/uploads/images/'); //self::recurseCopy(__DIR__.'/images/profile', __DIR__.'/../../../../../../web/uploads/images/profile'); //self::recurseCopy(__DIR__.'/images/product', __DIR__.'/../../../../../../web/uploads/images/product'); //slider //$this->createSliderFixtures(); }