<?php use Notes\Domain\ValueObject\StringLiteral; describe('StringLiteral', function () { describe('->__construct()', function () { it('should return a StringLiteral object', function () { $actual = new StringLiteral(); expect($actual)->to->be->instanceof('ValueObject\\StringLiteral'); }); }); describe('->__construct("foo")', function () { it('should return a StringLeteral object with the value of "foo"', function () { $value = 'foo'; $actual = new StringLiteral($value); expect($actual)->to->be->instanceof('ValueObject\\StringLiteral'); expect($actual->__toString())->equal($value); }); }); describe('->__toString()', function () { it('should return the default', function () { $actual = new StringLiteral(); expect($actual->__toString())->equal(''); }); it('should return "foo"', function () { $value = 'foo'; $actual = new StringLiteral($value); expect($actual->__toString())->equal($value); }); }); });
$actual = new StringLiteral($value); expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral'); expect($actual->__toString())->equal($value); }); }); describe('->__construct(123)', function () { it('should return an InvalidArgumentException', function () { $value = 123; $exception = null; try { new StringLiteral($value); } catch (Exception $e) { $exception = $e; } expect($exception)->to->be->instanceof('\\InvalidArgumentException'); }); }); describe('->__toString()', function () { it('should return the default value of StringLiteral', function () { $actual = new StringLiteral(); expect($actual->__toString())->equal(''); expect($actual->__toString())->empty(); }); it('should return "foo"', function () { $value = 'foo'; $actual = new StringLiteral($value); expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral'); expect($actual->__toString())->equal($value); }); }); });
$username = new StringLiteral($faker->userName); $user = new User($uuid, $username); $actual = $user->getId(); expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\Uuid'); expect($actual->__toString())->equal($uuid->__toString()); }); }); describe('->getUsername()', function () { it('should get the correct username', function () { $faker = \Faker\Factory::create(); $uuid = new Uuid(); $userName = new StringLiteral($faker->userName); $user = new User($uuid, $userName); $actual = $user->getUsername(); expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral'); expect($actual->__toString())->equal($userName->__toString()); }); }); describe('->get/setEmail()', function () { it('should set & get the correct email', function () { $faker = \Faker\Factory::create(); $uuid = new Uuid(); $userName = new StringLiteral($faker->userName); $user = new User($uuid, $userName); $email = new StringLiteral($faker->email); $user->setEmail($email); $actual = $user->getEmail(); expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral'); expect($actual->__toString())->equal($email->__toString()); }); });