/** * {@inheritdoc} */ public function save(User $user) { $stmt = $this->pdo->prepare('INSERT INTO users(`name`, `email`, `password`) VALUES (:name, :email, :password)'); $result = $stmt->execute(['name' => $user->getName(), 'email' => $user->getEmail(), 'password' => $user->getPassword()]); if (!$result) { throw new RuntimeException('Unable to save User Entity! ' . $stmt->errorInfo()[2]); } $this->idSetter->setEntityId($user, (int) $this->pdo->lastInsertId()); return $user; }
public function testDefaultValuesAreNull() { $user = new User($this->getMockEmail()); $this->assertNull($user->getName()); $this->assertNull($user->getPassword()); }