$uuid = new StringLiteral($faker->uuid); $actual = new User($uuid); expect($actual)->to->be->instanceof('Notes\\Domain\\Entity\\User'); }); }); describe('->__toString()', function () { it('should return a string with user information', function () { $faker = \Faker\Factory::create(); $uuid = new StringLiteral($faker->uuid); $actual = new User($uuid); expect(is_string($actual->__toString()))->equal(true); }); }); describe('->getId()', function () { it('should return the User\'s id', function () { $userFactory = new UserFactory(); $faker = \Faker\Factory::create(); $uuid = new StringLiteral($faker->uuid); $actual = new User($uuid); $actual = $userFactory->create(); expect($actual)->to->be->instanceof('Notes\\Domain\\Entity\\User'); expect($actual->getId())->to->be->instanceof('Notes\\Domain\\ValueObject\\Uuid'); }); }); describe('->getUsername()', function () { it('should return the User\'s username', function () { $faker = \Faker\Factory::create(); $uuid = new StringLiteral($faker->uuid); $username = new StringLiteral($faker->userName); $actual = new User($uuid); $actual->setUsername($username);
<?php /** * Created by PhpStorm. * User: andrewscheerenberger * Date: 11/17/15 * Time: 6:10 PM */ use Notes\Domain\Entity\UserFactory; describe('', function () { describe('->__construct()', function () { it('Should create a new UserFactory object', function () { $actual = new UserFactory(); expect($actual)->to->be->instanceof('Notes\\Domain\\Entity\\UserFactory'); }); }); describe('->create()', function () { it('Should create a new user object', function () { $factory = new UserFactory(); $actual = $factory->create(); expect($actual)->to->be->instanceof('Notes\\Domain\\Entity\\User'); }); }); });
<?php require_once __DIR__ . '/vendor/autoload.php'; //require_once __DIR__ . ''; use Silex\Application; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Notes\Persistence\Entity\MysqlUserRepository; use Notes\Domain\Entity\UserFactory; use Notes\Domain\ValueObject\StringLiteral; $app = new Application(); $app['debug'] = true; $dsn = 'mysql:dbname=testdb;host=127.0.0.1'; $username = '******'; $password = '******'; $repo = new MysqlUserRepository($dsn, $username, $password); $userFactory = new UserFactory(); $app->get('/', function () { return new Response('Final Project API', 200); }); $app->get('/users', function (Request $request) use($repo) { $sort = strtolower($request->get("sort-username")); $users = $repo->getUsers(); /* ran out of time cuz my virtual machine crashed, so i didnt implement them!! if($sort == 'dsc') { } elseif($sort == "asc") { }*/ return new Response(json_encode($users), 200, ['Content-Type' => 'application/json']); });