]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Administration/UpgradeHistoryTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / Administration / UpgradeHistoryTest.php
1 <?php
2 require_once 'modules/Administration/UpgradeHistory.php';
3
4 class UpgradeHistoryTest extends Sugar_PHPUnit_Framework_TestCase
5 {
6         public function testCheckForExistingSQL()
7     {
8         $patchToCheck = new stdClass();
9         $patchToCheck->name = 'abc';
10         $patchToCheck->id = '';
11             $GLOBALS['db']->query("INSERT INTO upgrade_history (id, name, date_entered) VALUES
12 ('444', 'abc','2008-12-20 08:08:20') ");
13             $GLOBALS['db']->query("INSERT INTO upgrade_history (id, name , date_entered) VALUES
14 ('555','abc', '2008-12-20 08:08:20')");
15                 $uh = new UpgradeHistory();
16         $return = $uh->checkForExisting($patchToCheck);
17                 $this->assertContains($return->id, array('444','555'));
18         
19         $patchToCheck->id = '555';
20         $return = $uh->checkForExisting($patchToCheck);
21         $this->assertEquals($return->id, '444');
22         
23         $GLOBALS['db']->query("delete from upgrade_history where id='444'");
24                 $GLOBALS['db']->query("delete from upgrade_history where id='555'");
25     }
26 }