$password = '******'; $user = new User(); $user->setPassword($password); // setPassword would likely only be used for empty user objects made by an admin or to reset a password $hashpass = hash(sha256, $password); expect($user->getPassword())->equal($hashpass); }); }); // tests password validation describe('->setPassword()', function () { it('should throw and invalid argument exception', function () { $invalidPass = "******"; $user = new User(); $exception = null; try { $user->setPassword($invalidPass); } catch (exception $e) { $exception = $e; } expect($exception)->to->be->instanceof('\\InvalidArgumentException'); }); }); // tests set and get password describe('->getEmail()', function () { it('should return the users email address', function () { $faker = \Faker\Factory::create(); $email = $faker->freeEmail; $user = new User(); $user->setEmail($email); // setPassword would likely only be used for empty user objects made by an admin or to reset a password expect($user->getEmail())->equal($email);