Пример #1
0
 /**
  * Method to test the save method.
  * @since 1.0.0
  * @test
  */
 public function testSave()
 {
     //the User Entity which will be created on database.
     $user_create = new User();
     $user_create->birthday = '1974-08-19';
     $user_create->email = '*****@*****.**';
     $user_create->firstname = 'Casey V.';
     $user_create->gender = 'F';
     $user_create->lastname = 'Wade';
     $user_create->password = '******';
     $user_create->salt = 'd02991c2a8e062a6d419883b6e3a1e58c4090029d1078b58c89c0f096177c379f0552bce705aaf47d7263a70cbf3e527c3662965d62d7cdf34df0053702c50ad';
     $user_create->username = '******';
     //the User Entity which will be updated on database.
     $user_update = new User();
     $user_update->id = 2;
     $user_update->birthday = '1996-08-17';
     $user_update->email = '*****@*****.**';
     $user_update->firstname = 'Ida Q.';
     $user_update->gender = 'F';
     $user_update->lastname = 'Garnes';
     $user_update->password = '******';
     $user_update->salt = 'd02991c2a8e062a6d419883b6e3a1e58c4090029d1078b58c89c0f096177c379f0552bce705aaf47d7263a70cbf3e527c3662965d62d7cdf34df0053702c50ad';
     $user_update->username = '******';
     //the UserMapper to save the User Entity (create) on database.
     $userMapper = new UserMapper($this->getConnection()->getConnection());
     $userMapper->save($user_create);
     //the UserMapper to save the User Entity (update) on database.
     $userMapper = new UserMapper($this->getConnection()->getConnection());
     $userMapper->save($user_update);
     //get the actual and expected table.
     $queryTable = $this->getConnection()->createQueryTable('user', 'SELECT * FROM user');
     $expectedDataSet = __DIR__ . '/DataSets/User/user-save.xml';
     $expectedTable = $this->createXMLDataSet($expectedDataSet)->getTable('user');
     //check whether the tables are equal.
     $this->assertTablesEqual($expectedTable, $queryTable);
     //the Clan Entity which should be fail.
     $clan = new Clan();
     $clan->id = 0;
     $clan->name = 'Example Team';
     $clan->tag = 'ET';
     //another Entity than User Entity is not valid on the UserMapper (create).
     $this->assertFalse($userMapper->save($clan));
     //another Entity than User Entity is not valid on the UserMapper (update).
     $clan->id = 1;
     $this->assertFalse($userMapper->save($clan));
 }
Пример #2
0
 /**
  * Method to test if the method update() works.
  * @since 0.0.1-dev
  * @test
  */
 public function testSaveUpdate()
 {
     //The User which will be updated on database.
     $user = new User();
     $user->id = 2;
     $user->birthday = '1996-08-17';
     $user->email = '*****@*****.**';
     $user->firstname = 'Ida Q.';
     $user->gender = 'F';
     $user->lastname = 'Garnes';
     $user->password = '******';
     $user->username = '******';
     //The UserMapper to update the User on database.
     $userMapper = new UserMapper($this->pdo);
     $userMapper->save($user);
     //Get the actual and expected table.
     $queryTable = $this->getConnection()->createQueryTable('user', 'SELECT * FROM user');
     $expectedDataSet = __DIR__ . '/DataSets/User/user-save-update.xml';
     $expectedTable = $this->createXMLDataSet($expectedDataSet)->getTable('user');
     //Check if the tables are equal.
     $this->assertTablesEqual($expectedTable, $queryTable);
 }