]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/Bug42643Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / Bug42643Test.php
1 <?php
2
3 require_once('modules/UpgradeWizard/uw_utils.php');
4
5 class Bug42643Test extends Sugar_PHPUnit_Framework_TestCase 
6 {
7         var $has_notification_studio_file = false;
8         var $studio_file = 'modules/Help/Forms.php';
9         var $backup_file;
10         
11         public function setUp() 
12         {
13                 
14                 if(file_exists($this->studio_file))
15                 {
16                    //This really shouldn't be happening, but just in case...
17                    $this->has_notification_studio_file = true;
18                    $this->backup_file = $this->studio_file . '.' . gmmktime() . '.bak';
19                    copy($this->studio_file, $this->backup_file);
20                 } else {
21                    //Create the test file
22                    write_array_to_file("test", array(), $this->studio_file);
23                 }
24         }
25         
26         public function tearDown() 
27         {
28                 if($this->has_notification_studio_file)
29                 {
30                    copy($this->backup_file, $this->studio_file);
31                    unlink($this->backup_file);
32                 } else {
33                    if(file_exists($this->studio_file))
34                    {
35                                 unlink($this->studio_file);
36                    }
37                 }
38         }
39
40         public function testUnlinkUpgradeFilesPre614()
41         {
42                 $this->assertTrue(file_exists($this->studio_file), 'Assert the ' . $this->studio_file . ' exists');
43                 unlinkUpgradeFiles('610');
44                 $this->assertFalse(file_exists($this->studio_file), 'Assert the ' . $this->studio_file . ' no longer exists');
45         }       
46 }