Example #1
0
 /**
  * Method to test the save method.
  * @since 1.0.0
  * @test
  */
 public function testSave()
 {
     //the Clan Entity which will be created on database.
     $clan_create = new Clan();
     $clan_create->name = 'Killerbees eSport';
     $clan_create->tag = 'KBE';
     $clan_create->website = 'http://example.com/';
     //the Clan Entity which will be updated on database.
     $clan_update = new Clan();
     $clan_update->id = 2;
     $clan_update->name = 'Clanify Gaming';
     $clan_update->tag = 'CG';
     $clan_update->website = 'http://clanify.rocks/gaming';
     //the ClanMapper to save the Clan Entity (create) on database.
     $clanMapper = new ClanMapper($this->getConnection()->getConnection());
     $clanMapper->save($clan_create);
     //the ClanMapper to save the Clan Entity (update) on database.
     $clanMapper = new ClanMapper($this->getConnection()->getConnection());
     $clanMapper->save($clan_update);
     //get the actual and expected table.
     $actualTable = $this->getConnection()->createQueryTable('clan', 'SELECT * FROM clan');
     $expectedDataset = __DIR__ . '/DataSets/Clan/clan-save.xml';
     $expectedTable = $this->createXMLDataSet($expectedDataset)->getTable('clan');
     //check whether the tables are equal.
     $this->assertTablesEqual($expectedTable, $actualTable);
     //the Team Entity which should be fail.
     $team = new Team();
     $team->id = 0;
     $team->name = 'Example eSport';
     $team->tag = 'EE';
     //another Entity than Clan Entity is not valid on the ClanMapper (create).
     $this->assertFalse($clanMapper->save($team));
     //another Entity than Clan Entity is not valid on the ClanMapper (update).
     $team->id = 1;
     $this->assertFalse($clanMapper->save($team));
 }
Example #2
0
 /**
  * Method to test if the method update() works.
  * @since 0.0.1-dev
  * @test
  */
 public function testSaveUpdate()
 {
     //The Clan which will be updated on database.
     $clan = new Clan();
     $clan->id = 2;
     $clan->name = 'Clanify eSport';
     $clan->tag = 'CeS';
     $clan->website = 'http://clanify.rocks/esport';
     //The ClanMapper to update the Clan on database.
     $clanMapper = new ClanMapper($this->pdo);
     $clanMapper->save($clan);
     //Get the actual and expected table.
     $queryTable = $this->getConnection()->createQueryTable('clan', 'SELECT * FROM clan');
     $expectedDataSet = __DIR__ . '/DataSets/Clan/clan-save-update.xml';
     $expectedTable = $this->createXMLDataSet($expectedDataSet)->getTable('clan');
     //Check if the tables are equal.
     $this->assertTablesEqual($expectedTable, $queryTable);
 }