Index: /trunk/Tests/TestAngle.php
===================================================================
--- /trunk/Tests/TestAngle.php	(revision 411)
+++ /trunk/Tests/TestAngle.php	(revision 411)
@@ -0,0 +1,97 @@
+<?php
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/Astro/Angle.php';
+
+
+
+class TestAngle extends BaseTest
+{
+  public function TestIt()
+  {
+    $a0 = new Angle();
+    $a0->FromRadians( M_PI/2.0 );
+    $a1 = new Angle( $a0 );
+    
+    $this->PerformTest( 'Testing constructor with value',
+			( $a1->ToRadians() == (M_PI/2.0) ),
+			'Failed to construct with given value' );
+    
+    $a1->FromRadians( pi() );
+    $this->PerformTest( 'Testing basic getter/setter methods ',
+			( $a1->ToRadians() == M_PI ),
+			'Failed to retrieve radians as set' );
+    
+    $this->PerformTest( 'Testing retreiving as degrees',
+			( $a1->ToDegrees() == 180.0 ),
+			'Failed to retreive as degrees' );
+    
+    $this->PerformTest( 'Testing retreiving as hms string',
+			( $a1->ToHMSString() == '12:00:00' ),
+			'Failed to retreive as hms string' . $a1->ToHMSString() );
+    
+    $this->TestDegToHMS( 171.1, 11, 24, 24 );
+    $this->TestDegToHMS( 170, 11, 20, 0 );
+    $this->TestDegToHMS( 180, 12, 0, 0 );
+    $this->TestDegToHMS( 180.01, 12, 0, 2.4 );
+    $this->TestDegToHMS( 179.99, 11, 59, 57.6 );
+    
+    $this->TestDegToDMS( 179.99, 179, 59, 24.0 );
+    
+    $this->TestFromDMSString( 179.99, '179:59:24' );
+    $this->TestFromDMSString( 180.00, '180:00:00' );
+    $this->TestFromDMSString( 30.0, '29:59:59' );
+  }
+  
+  private function TestDegToHMS( $degrees, $hours_expected, $mins_expected, $secs_expected )
+  {
+    $a1 = new Angle();
+    
+    $a1->FromDegrees( $degrees );
+    
+    $hours = 1;
+    $mins = 2;
+    $secs = 3.0;
+    
+    $hms_string = $a1->ToHMS( $hours, $mins, $secs );
+    $secs = round( $secs, 3 );
+    $this->PerformTest( 'Testing Degrees To HMS conversion ' . $degrees,
+			( $hours == $hours_expected && $mins == $mins_expected && $secs == $secs_expected ),
+			'Failed to retreive hms by values ' . "$hours:$mins:$secs " .
+			' should be ' . "$hours_expected:$mins_expected:$secs_expected" );
+  }
+  
+  private function TestDegToDMS( $degrees, $degrees_expected, $mins_expected, $secs_expected )
+  {
+    $a1 = new Angle();
+    
+    $a1->FromDegrees( $degrees );
+    
+    $degrees_returned = 1;
+    $mins = 2;
+    $secs = 3.0;
+    
+    $hms_string = $a1->ToDMS( $degrees_returned, $mins, $secs );
+    $secs = round( $secs, 3 );
+    $this->PerformTest( 'Testing Degrees To DMS conversion ' . $degrees,
+			( $degrees_returned == $degrees_expected && $mins == $mins_expected && $secs == $secs_expected ),
+			'Failed to retreive hms by values ' . "$degrees_returned:$mins:$secs " .
+			    ' should be ' . "$degrees_expected:$mins_expected:$secs_expected" );
+  }
+  
+  private function TestFromDMSString( $degrees_expected, $dms_string )
+  {
+    $angle = new Angle();
+    
+    $angle->FromDMSString( $dms_string );
+    $degrees_returned = round( $angle->ToDegrees(), 2 );
+    $this->PerformTest( 'Testing From DMS ',
+			( $degrees_returned == $degrees_expected ),
+			" Failed to retreive degress from a dms got $degrees_returned expected $degrees_expected" );
+  }
+};
+
+?>
Index: /trunk/Tests/TestBand.php
===================================================================
--- /trunk/Tests/TestBand.php	(revision 411)
+++ /trunk/Tests/TestBand.php	(revision 411)
@@ -0,0 +1,23 @@
+<?php
+
+
+
+
+
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/Astro/Band.php';
+
+
+
+
+class TestBand extends BaseTest
+{
+};
+
+
+?>
+
+
+
+
+
Index: /trunk/Tests/TestDate.php
===================================================================
--- /trunk/Tests/TestDate.php	(revision 411)
+++ /trunk/Tests/TestDate.php	(revision 411)
@@ -0,0 +1,48 @@
+<?php
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/General/Date.php';
+
+
+
+class TestDate extends BaseTest
+{
+  function TestIt()
+  {
+    $day = '1';
+    $month = '2';
+    $year = '2008';
+  
+    $d1 = new Date();
+    $d1->SetDayOfMonth( $day );
+  
+    $this->PerformTest( 'Testing day getter/setter',
+		( $day == $d1->GetDayOfMonth() ),
+		'Failed to retrieve the day we set' );
+  
+    $d1->SetMonthOfYear( $month );
+    $this->PerformTest( 'Testing month getter/setter',
+		( $month == $d1->GetMonthOfYear() ),
+		'Failed to retrieve the month we set' );
+  
+    $d1->SetYear( $year );
+    $this->PerformTest( 'Testing year getter/setter',
+		( $year == $d1->GetYear() ),
+		'Failed to retrieve the year we set' );
+  
+    $d1->FromDMYString( '12/12/1212' );
+    $this->PerformTest( 'Testing DMY getter/setter',
+		( $d1->ToDMYString() == '12/12/1212' ),
+		'The date set and retrieved do not match' . $d1->ToDMYString() );
+    
+    $this->PerformTest( 'Testing DMY getter 2 (month is string)',
+                        ( $d1->ToDMYString2() == '12/Dec/1212' ),
+                          'Failed to retrieve date with text month ' . $d1->ToDMYString2() );
+  }
+}
+
+
+?>
Index: /trunk/Tests/TestDateRange.php
===================================================================
--- /trunk/Tests/TestDateRange.php	(revision 411)
+++ /trunk/Tests/TestDateRange.php	(revision 411)
@@ -0,0 +1,37 @@
+<?php
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/General/DateRange.php';
+
+
+class TestDateRange extends BaseTest
+{
+  public function TestIt()
+  {
+  // test the from date setter/getter
+  // test the to date setter/getter
+
+  $from_date = new Date();
+  $from_date->FromDMYString( '12/12/1212' );
+
+  $date_range = new DateRange();
+  $date_range->SetFromdate( $from_date );
+  $this->PerformTest( 'Testing from date getter/setter',
+	       ( $date_range->GetFromDate()->ToDMYString() == '12/12/1212' ),
+	       'From date retrieved does not match from date set' );
+
+  $to_date = new Date();
+  $to_date->FromDMYString( '11/11/1111' );
+
+  $date_range->SetToDate( $to_date );
+  $this->PerformTest( 'Testing to date getter/seetter',
+	       ( $date_range->GetToDate()->ToDMYString() == '11/11/1111' ),
+	       'To date retrieved does not match to date set' );
+  }
+};
+
+
+?>
Index: /trunk/Tests/TestDir.php
===================================================================
--- /trunk/Tests/TestDir.php	(revision 411)
+++ /trunk/Tests/TestDir.php	(revision 411)
@@ -0,0 +1,92 @@
+<?php
+
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/General/Dir.php';
+require_once 'Classes/General/File.php';
+
+
+
+class TestDir extends BaseTest
+{
+  public function TestIt()
+  {
+    // get a temporary filename
+    // test that there is no dir with that name
+    // create a directory using that tmpfile name
+    // test that the new directory exists as a directory
+    // create a test file in the directory
+    // test that the test file was created correctly
+    // get the list of files in the directory
+    // test that the list simply contains the test file
+    // delete the test file
+    // remove the directory
+    // test that the directory no longer exists
+  
+    $tmp_file = new File();
+    $tmp_file->SetFullPath( tempnam('','') );
+    $tmp_file->Remove();
+    
+    $dir = new Dir();
+    $dir->SetPath( $tmp_file->GetFullPath() );
+    
+    $this->PerformTest( 'Testing temp file doesnt exist',
+		( !$tmp_file->Exists() ),
+		'The file created by tempnam still exists' );
+    
+    $this->PerformTest( 'Testing temp dir does not exist',
+		( !$dir->IsDir() ),
+		'The test directory exists for some reason ' . $dir->GetPath() );
+    
+    $dir->Create();
+    
+    $this->PerformTest( 'Test that we created the directory successfully',
+		( $dir->IsDir() ),
+		'Failed to create the directory ' . $dir->GetPath() );
+    
+    $test_file = new File();
+    $test_file->SetPath( $dir->GetPath() );
+    $test_file->SetFilename( 'testing' );
+    $test_file->Create();
+    $this->PerformTest( 'Testing we can create a file in the new directory',
+		( $test_file->Exists() ),
+		'Failed to create file called testing in directory' . $dir->GetPath() );
+    
+    $all_files = $dir->ListFiles();
+    $this->PerformTest( 'Testing we have the correct number of files from the directory',
+		( count($all_files) == 3 ),
+		'Wrong number of files listed in directory ' . count($all_files) );
+    
+    $this->PerformTest( 'Testing the file we want is listed correctly',
+		( $all_files[1] == 'testing' ),
+		'The file "testing" is not there' );
+    
+    $test_file->Remove();
+    $this->PerformTest( 'testing we removed the test file successfully',
+		( !$test_file->Exists() ),
+		'Failed to remove the test file from out test directory' );
+    
+    $dir->Remove();
+    
+    $this->PerformTest( 'Test that we can remove the directoroy',
+		( !$dir->IsDir() ),
+		'Failed to remove the directory ' . $dir->GetPath() );
+    
+    $td2 = Dir::ConvertPathString( '/mydir/mysubdir' );
+    $this->PerformTest( 'Testing construction from path string',
+                        ( $td2->GetPath() == '/mydir/mysubdir' ),
+                          'Failed to create a Dir using a path string' );
+    
+    $td2->SubtractBasePath( Dir::ConvertPathString( '/mydir' ) );
+    $this->PerformTest( 'Testing base path subtraction',
+                        ( $td2->GetPath() == 'mysubdir' ),
+                          'Failed to correctly subtract base path' . $td2->GetPath() );
+                          
+  }
+};
+
+
+?>
Index: /trunk/Tests/TestFile.php
===================================================================
--- /trunk/Tests/TestFile.php	(revision 411)
+++ /trunk/Tests/TestFile.php	(revision 411)
@@ -0,0 +1,71 @@
+<?php
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/General/File.php';
+
+
+
+class TestFile extends BaseTest
+{
+  public function TestIt()
+  {
+    $tmp_name = tempnam( '', 'FileTest');
+    $tmp_dir = substr( $tmp_name, 0, strrpos( $tmp_name, '/' ) );
+    $tmp_file = substr( $tmp_name, strrpos( $tmp_name, '/' ) + 1 );
+
+    $f1 = new File();
+
+    $f1->SetPath( $tmp_dir );
+    $this->PerformTest( 'Testing path Getter/Setters',
+		 ($f1->GetPath() == $tmp_dir),
+		 'Path retreived does not match path entered' );
+
+    $f1->SetFilename( $tmp_file );
+    $this->PerformTest( 'Testing filename Getter/Setter',
+		 ($f1->GetFilename() == $tmp_file ),
+		 'Filename retreived does not match filenamed entered' );
+
+    $this->PerformTest( 'Testing GetFullPath function',
+		 ($f1->GetFullPath() == $tmp_name),
+		 'Full path returned does not match the path and filename set' );
+  
+    $f1->SetFullPath( $tmp_name );
+    $this->PerformTest( 'Testing SetFullPath breaks up correctly',
+		 ($f1->GetPath() == $tmp_dir),
+		 'The path was not extracted from the full path correctly' );
+
+    $this->PerformTest( 'Testing SetFullPath separates filename correctly',
+		 ($f1->GetFilename() == $tmp_file),
+		 'The filename was not extracted from the full path correctly' );
+  
+    $this->PerformTest( 'Testing tempnam created the file',
+		 ($f1->Exists()),
+		 'The file specified doesnt exist' . $f1->GetFullPath() );
+
+    $this->PerformTest( 'Testing directory test',
+		 (!$f1->IsDir()),
+		 'The file specified is a directory ???' );
+
+    $this->PerformTest( 'Testing link test',
+		 (!$f1->IsLink()),
+		 'The file specified is a link ???' );
+
+    $f1->Remove();
+
+    $this->PerformTest( 'Testing file deletion',
+		 ( !$f1->Exists() ),
+		 'The file still exists' . $f1->GetFullPath() );
+
+    $f1->Create();
+
+    $this->PerformTest( 'Testing file creation',
+		 ( $f1->Exists() ),
+		 'The file wasnt created' . $f1->GetFullPath() );
+  }
+};
+
+
+?>
Index: /trunk/Tests/TestMJD.php
===================================================================
--- /trunk/Tests/TestMJD.php	(revision 411)
+++ /trunk/Tests/TestMJD.php	(revision 411)
@@ -0,0 +1,30 @@
+<?php
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/Astro/MJD.php';
+
+
+
+class TestMJD extends BaseTest
+{
+  public function TestIt()
+  {
+    $target_date = new Date();
+    $target_date->FromYMDString( '2008-01-01' );
+    echo $target_date->ToDMYString() . ' <br> ';
+    $target_mjd = new MJD();
+    $target_mjd->FromDate( $target_date );
+    echo $target_mjd->ToString() , ' <br> ';
+    $new_value = $target_mjd->ToString() - 365;
+    $adjusted_mjd = new MJD();
+    $adjusted_mjd->FromString( $new_value );
+    $adjusted_date = $adjusted_mjd->ToDate();
+    echo $adjusted_date->ToDMYString() . ' <br> ';
+  }
+};
+
+
+?>
Index: /trunk/Tests/TestObservationData2.php
===================================================================
--- /trunk/Tests/TestObservationData2.php	(revision 411)
+++ /trunk/Tests/TestObservationData2.php	(revision 411)
@@ -0,0 +1,133 @@
+<?php
+
+
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/General/File.php';
+require_once 'Classes/Model/Observation.php';
+require_once 'Classes/Pulsar/ObservationData2.php';
+
+
+
+
+class TestObservationData2 extends BaseTest
+{
+  public function TestIt()
+  {
+    $this->TestCPSR2Data();
+    $this->TestDFBData();
+  }
+
+  /**
+   * Create a File pointing at the CPSR2 test dir
+   *
+   * Create an Observation object
+   * Set some test fields including filename,data_loc
+   *
+   * Create an ObservationData2 object
+   * set the observation
+   * Set the data directory
+   *
+   * Get the original file and check it
+   * Get the data file and check it
+   * Get the scrunched file and check it
+   **/
+  public function TestCPSR2Data()
+  {
+    $cpsr2_path = '/pulsar/archive05/CPSR2/J0437-4715/2006-04-11-05:10:39';
+    $data_path = '/pulsar/scratch01/data_archive';
+    $expected_data_file = File::ConvertFullPath( $data_path . '/' . '2006-04-11-05:10:39' );
+    $expected_scr_file = File::ConvertFullPath( $data_path .'/' . '2006-04-11-05:10:39_T1F128p' );
+
+    $cpsr2_file = File::ConvertFullPath( $cpsr2_path );
+    $data_dir = Dir::ConvertPathString( $data_path );
+    
+    $obs = new Observation();
+    $obs->SetFile( $cpsr2_file );
+    
+    $data = new ObservationData2();
+    $data->SetObservationHeader( $obs );
+    $data->SetDataDir( $data_dir );
+    
+    $scr_params = new ScrunchingParameters();
+    $scr_params->SetTScrunch( 1 );
+    $scr_params->SetFScrunch( 128 );
+    $scr_params->SetPScrunch();
+    
+    $data->SetScrunchingParameters( $scr_params );
+    
+    $original_file = $data->GetOriginalFile();
+    $data_file = $data->GetDataFile();
+    $scrunched_file = $data->GetScrunchedFile();
+    
+    $this->PerformTest( 'Testing GetOriginalFile',
+                        ( $original_file->GetFullPath() == $cpsr2_path ),
+                          'ObservationData2 returned the wrong path ' . $cspr2_path );
+    
+    $this->PerformTest( 'Testing GetDataFile',
+                         ( $expected_data_file->GetFullPath() == $data_file->GetFullPath() ),
+                           'Failed to create data file ' . $expected_data_file->GetFullPath() . ' ' . $data_file->GetFullPath() );
+    
+    $this->PerformTest( 'Testing GetScrunchedFile',
+                        ( $expected_scr_file->GetFullPath() == $scrunched_file->GetFullPath() ),
+                          'Failed to create scrunched file ' . $expected_scr_file->GetFullPath() . ' ' . $scrunched_file->GetFullPath() );
+  }
+
+  /**
+   * Create a File pointing at the DFB test dir
+   *
+   * Create an Observation object
+   * Set some test fields including filename,data_loc
+   *
+   * Create an ObservationData2 object
+   * set the observation
+   * Set the data directory
+   *
+   * Get the original file and check it
+   * Get the data file and check it
+   * Get the scrunched file and check it
+   **/
+  public function TestDFBData()
+  {
+    $src_archive = File::ConvertFullPath( '/pulsar/archive12/DFB/J1019-5749_R/r080208_114145.cf' );
+    $data_dir = Dir::ConvertPathString( '/pulsar/scratch01/data_archive' );
+    $expected_data_file = File::ConvertFullPath( '/pulsar/scratch01/data_archive/r080208_114145.cf' );
+    $expected_scr_file = File::ConvertFullPath( '/pulsar/scratch01/data_archive/r080208_114145_T1F128p.cf' );
+    
+    $obs = new Observation();
+    $obs->SetFile( $src_archive );
+    
+    $data = new ObservationData2();
+    $data->SetObservationHeader( $obs );
+    $data->SetDataDir( $data_dir );
+    
+    $scr_params = new ScrunchingParameters();
+    $scr_params->SetTScrunch( 1 );
+    $scr_params->SetFScrunch( 128 );
+    $scr_params->SetPScrunch();
+    
+    $data->SetScrunchingParameters( $scr_params );
+    
+    $original_file = $data->GetOriginalFile();
+    $data_file = $data->GetDataFile();
+    $scrunched_file = $data->GetScrunchedFile();
+    
+    $this->PerformTest( 'Testing GetOriginalFile',
+                        ( $original_file->GetFullPath() == $src_archive->GetFullPath() ),
+                          'ObservationData2 returned the wrong path ' . $original_file->GetFullPath() );
+    
+    $this->PerformTest( 'Testing GetDataFile',
+                        ( $expected_data_file->GetFullPath() == $data_file->GetFullPath() ),
+                          'Failed to create data file ' . $expected_data_file->GetFullPath() . ' ' . $data_file->GetFullPath() );
+    
+    $this->PerformTest( 'Testing GetScrunchedFile',
+                        ( $expected_scr_file->GetFullPath() == $scrunched_file->GetFullPath() ),
+                          'Failed to create scrunched file ' . $expected_scr_file->GetFullPath() . ' ' . $scrunched_file->GetFullPath() );
+  }
+};
+
+?>
+
Index: /trunk/Tests/TestSkyCoord.php
===================================================================
--- /trunk/Tests/TestSkyCoord.php	(revision 411)
+++ /trunk/Tests/TestSkyCoord.php	(revision 411)
@@ -0,0 +1,27 @@
+<?php
+
+
+
+require_once 'config.php';
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/Astro/SkyCoord.php';
+
+
+
+class TestSkyCoord extends BaseTest
+{
+  public function TestIt()
+  {
+    $coord_string = '01:02:30 04:05:06.000';
+
+    $c1 = new SkyCoord();
+    $c1->FromHMSDMSString( $coord_string );
+
+    $this->PerformTest( 'Testing SkyCoord SetHMSDMS/GetHMSDMS ',
+		 ( $coord_string == $c1->ToHMSDMSString() ),
+		 'Result read from GetHMSDMS does not match string given in SetHMSDMS ' .
+                      $c1->ToHMSDMSString() );
+  }
+}
+
+?>
Index: /trunk/Tests/TestTarBuilder.php
===================================================================
--- /trunk/Tests/TestTarBuilder.php	(revision 411)
+++ /trunk/Tests/TestTarBuilder.php	(revision 411)
@@ -0,0 +1,18 @@
+<?php
+
+
+
+
+
+require_once GREEN_ZONE_DIR . 'Tests/BaseTest.php';
+require_once 'Classes/General/TarBuilder.php';
+
+
+
+
+class TestTarBuilder extends BaseTest
+{
+};
+
+
+?>
