/** * Save credentials * * @param array $args Credentials to save * @return \App\Entity\Credentials */ public function save($args) { // Limit expiry times if ($args['expires'] < 60 * 60 || $args['expires'] > 60 * 60 * 24 * 30) { $args['expires'] = 60 * 60; } $args['expires'] = time() + $args['expires']; $credentials = $this->credentialsFactory->getInstance(); $credentials->setUserName($args['userName']); $credentials->setPassword($args['password']); $credentials->setComment($args['comment']); $credentials->setExpires($args['expires']); $this->encryptProperties($credentials); $this->em->persist($credentials); $this->em->flush(); $this->decryptProperties($credentials); return $credentials; }
/** * Test if hash is initialized * * @return void */ public function testHashIsInitialized() { $instance = $this->credentialsFactory->getInstance(); $this->assertNotEmpty($instance->getHash()); $this->assertSame(10, strlen($instance->getHash())); }