} 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); }); }); // tests email validation describe('->setEmail()', function () { it('should throw an invalid argument exception', function () { $invalidEmail = "IAmNotGivingMyEmailToAMachine"; $user = new User(); $exception = null; try { $user->setEmail($invalidEmail); } catch (exception $e) { $exception = $e; } expect($exception)->to->be->instanceof('\\InvalidArgumentException'); }); }); // don't need to test set and get name info. that is already tested with the stringliteral tests });
}); describe('->getId()', function () { it('should return the user\'s id', function () { $faker = \Faker\Factory::create(); $username = new StringLiteral($faker->userName); $user = new User($username); expect($user->getId())->to->be->instanceof('Notes\\Domain\\ValueObject\\Uuid'); }); }); describe('->getEmail()', function () { it('should return the user\'s email', function () { $faker = \Faker\Factory::create(); $username = new StringLiteral($faker->userName); $user = new User($username); $email = new StringLiteral($faker->email); $user->setEmail($email); expect($user->getEmail())->equal($email); }); }); describe('->getFirstName()', function () { it('should return the user\'s first name', function () { $faker = \Faker\Factory::create(); $username = new StringLiteral($faker->userName); $user = new User($username); $first = new StringLiteral($faker->firstName); $user->setFirstName($first); expect($user->getFirstName())->equal($first); }); }); describe('->getLastName()', function () { it('should return the user\'s last name', function () {