public function modifyById(Uuid $id, User $user)
 {
     mysqli_query($this->connection, "UPDATE `user` SET `id`='" . $user->getId() . "'," . "`username`='" . $user->getUsername() . "',`firstName`='" . $user->getFirstName() . "',`lastName`='" . $user->getLastName() . "' WHERE `id` = '{$id}';");
     if (mysqli_affected_rows($this->connection) > 0) {
         return true;
     }
     return false;
 }
 /**
  * @param User $user
  * @return mixed
  */
 public function add(User $user)
 {
     $userID = $user->getUserID();
     $userName = $user->getUserName();
     $userPassword = $user->getPassword();
     $userFirst = $user->getFirstName();
     $userLast = $user->getLastName();
     $userEmail = $user->getEmail();
     $query = "INSERT INTO USERS(UserID, UserName, UserPassword, UserFirst, UserLast, UserEmail) VALUES('{$userID}', '{$userName}', '{$userPassword}', '{$userFirst}', '{$userLast}', '{$userEmail}') ";
     mysql_query($query) or die("Database access failed: " . mysql_error());
 }
 /**
  * @param \Notes\Domain\ValueObject\Uuid $search
  * @param \Notes\Domain\Entity\User $newUser
  */
 public function modifyById(Uuid $search, User $newUser)
 {
     $results = [];
     foreach ($this->users as $user) {
         /** @var \Notes\Domain\Entity\User $userToGet */
         if ($user->getId()->__toString() === $search->__toString()) {
             $results[] = $user;
         }
     }
     if ($this->count() == 1) {
         $results[0]->setFirstName($newUser->getFirstName());
         $results[0]->setLastName($newUser->getLastName());
     }
     foreach ($results as $user) {
         $user->setFirstName($newUser->getFirstName());
         $user->setLastName($newUser->getLastName());
     }
 }
예제 #4
0
            $user = new User($id, $firstName, $lastName, $email);
            expect($user->getEmail())->equal($email);
        });
    });
    describe('-->setFirstName()', function () {
        it('should change the userFirstName to the given value.', function () {
            $faker = \Faker\Factory::create();
            $id = new Uuid();
            $firstName = new StringLiteral($faker->firstName);
            $lastName = new StringLiteral($faker->lastName);
            $email = new StringLiteral($faker->email);
            $user = new User($id, $firstName, $lastName, $email);
            $testFirstName = $faker->firstName;
            $user->setFirstName($testFirstName);
            expect($user->getFirstName())->equal($testFirstName);
        });
    });
    describe('-->setLastName()', function () {
        it('should change the userLastName to the given value.', function () {
            $faker = \Faker\Factory::create();
            $id = new Uuid();
            $firstName = new StringLiteral($faker->firstName);
            $lastName = new StringLiteral($faker->lastName);
            $email = new StringLiteral($faker->email);
            $user = new User($id, $firstName, $lastName, $email);
            $testLastName = $faker->lastName;
            $user->setLastName($testLastName);
            expect($user->getLastName())->equal($testLastName);
        });
    });
});
            expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral');
            expect($actual->__toString())->equal($email->__toString());
        });
    });
    describe('->get/setFirstName()', function () {
        it('should get/set the user\' first name', function () {
            $faker = \Faker\Factory::create();
            $uuid = new Uuid();
            $userName = new StringLiteral($faker->userName);
            $user = new User($uuid, $userName);
            $firstName = new StringLiteral($faker->firstName);
            $user->setFirstName($firstName);
            $actual = $user->getFirstName();
            expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral');
            expect($actual->__toString())->equal($firstName->__toString());
        });
    });
    describe('->get/setLastName()', function () {
        it('should get/set the user\' last name', function () {
            $faker = \Faker\Factory::create();
            $uuid = new Uuid();
            $userName = new StringLiteral($faker->userName);
            $user = new User($uuid, $userName);
            $lastName = new StringLiteral($faker->lastName);
            $user->setLastName($lastName);
            $actual = $user->getLastName();
            expect($actual)->to->be->instanceof('Notes\\Domain\\ValueObject\\StringLiteral');
            expect($actual->__toString())->equal($lastName->__toString());
        });
    });
});