<commit_before><?php
require_once 'phpunit-0.5/phpunit.php';
require_once("util.php");

class OGRSFDriverMiscellaneousTest1 extends PHPUnit_TestCase {
    var $strPathToData;
    var $strPathToOutputData;
    var $bUpdate;
    var $hOGRSFDriver;
    var $strFilename;
    var $strCapability;

    // constructor of the test suite
    function OGRSFDriverMiscellaneousTest1($name){
        printf("in constructor OGRSFDriverMiscellaneousTest\n");

        $this->PHPUnit_TestCase($name);
    }
    // called before the test functions will be executed    
    // this function is defined in PHPUnit_TestCase and overwritten 
    // here
    function setUp() {
        $this->strPathToData = "./data/mif";
        $this->strPathToOutputData = "../../ogrtests/testcase/";
        $this->strFilename = "NewDataSource";
        $this->bUpdate = FALSE;
        $this->strCapability = ODrCCreateDataSource;
    }
    // called after the test functions are executed    
    // this function is defined in PHPUnit_TestCase and overwritten 
    // here    
    function tearDown() {
        // delete your instance
        unset($this->strPathToData);
        unset($this->strPathToOutputData);
        unset($this->strFilename);
        unset($this->bUpdate);
        unset($this->strCapability);
    }
    /*Registered drivers supposed to be zero.*/
    function testOGRGetDriverCount1() {
        $result = OGRGetDriverCount();
        printf("result = %d\n", $result);
        $expected = 0;
        $this->assertEquals($expected, $result, "Driver count is supposed".
                            " to be ".expected, 0 /*$delta*/);
    }

    /*Adding one driver.  PROBLEM WITH OGRGetDriver when no registered
      driver exist.  TO COME BACK TO.*/
/*    function testOGRGetDriverCount2() {
        $result = OGRGetDriver(0);
        printf("driver = %d\n", $result);
        $this->assertNull($result, "Return driver is not NULL");
        $result = OGRGetDriverCount();
        printf("result = %d\n", $result);
        $expected = 0;
        $this->assertEquals($expected, $result, "Driver count is supposed".
                            " to be ".expected, 0 );
    }
*/
    /*Verify driver count with all drivers registered.*/
    function testOGRGetDriverCount3() {
        OGRRegisterAll();
        $result = OGRGetDriverCount();
        printf("result = %d\n", $result);
        $expected = 10;
        $this->assertEquals($expected, $result, "Driver count is supposed".
                            " to be".$expected, 0 /*$delta*/);
    }

    /*Verify driver count after registering a new driver.
     ERROR TO COME BACK TO.  OGRRegisterDriver seems to have 
     no utility here.  hOGRSFDriver is not supposed to be null
    after calling OGROpen().*/
    function testOGRGetDriverCount4() {

        $result = OGROpen($this->strPathToData, $this->bUpdate, 
                          $this->hOGRSFDriver);
        printf("result = %d\n", $result);
        $this->assertNotNull($result, "hOGRDataSource is NULL");
        $result = OGRGetDriverCount();
        printf("result = %d\n", $result);
        $expected = 10;
        $this->assertEquals($expected, $result, "Driver count is supposed".
                            " to be".$expected, 0 /*$delta*/);
        OGRRegisterDriver($this->hOGRSFDriver);
        $result = OGRGetDriverCount();
        printf("result = %d\n", $result);
        $expected = 10;
        $this->assertEquals($expected, $result, "Driver count is supposed".
                            " to be".$expected, 0 /*$delta*/);
    }
    /*Get a driver handle after execution OGRRegisterAll() in a preceeding
      test unit.*/
    function testOGRGetDriver1() {
        $result = OGRGetDriver(0);
        printf("driver = %d\n", $result);
        $this->assertNotNull($result, "Driver zero is not supposed".
                            " to be NULL");
    }
    /*Getting a driver with an id out of range.*/
    function testOGRGetDriver2() {
        $result = OGRGetDriver(50);
        printf("driver = %d\n", $result);
        $this->assertNull($result, "Driver zero is supposed".
                            " to be NULL");
    }
    /*Adding an existing driver has no effect.*/
    function testOGRGetDriver3() {
        $hDriver = OGRGetDriver(2);
        printf("driver = %d\n", $hDriver);
        $this->assertNotNull($hDriver, "Driver zero is not supposed".
                            " to be NULL");
        OGRRegisterDriver($hDriver);
        $nDriverCount = OGRGetDriverCount();
        printf("result = %d\n", $nDriverCount);
        $expected = 10;
        $this->assertEquals($expected, $nDriverCount, "Driver count is".
                            "supposed to be".$expected, 0 /*$delta*/);
    }
    /*Getting driver name.*/
    function testOGR_Dr_GetName1() {
        $hDriver = OGRGetDriver(7);
        $strDriverName = OGR_Dr_GetName($hDriver);
        printf("Driver name= %s\n", $strDriverName);
        $expected = "GML";
        $this->assertEquals($expected, $strDriverName, "Driver name is not".
                            "corresponding\n");
    }

    /*Creating a data source with MapInfo File driver*/
    function testOGR_Dr_CreateDataSource1(){

        printf("Source name =%s\n", $this->strPathToOutputData.$this->strFilename);

        $hDriver = OGRGetDriver(5);
        $astrOptions[0] = "FORMAT=MIF";
        system( "rm -R ".$this->strPathToOutputData.$this->strFilename);
        $hDataSource = OGR_Dr_CreateDataSource($hDriver, 
                                               $this->strPathToOutputData.
                                               $this->strFilename,
                                               $astrOptions );
        $this->assertNotNull($hDataSource, "New data source is NULL\n");
        OGR_DS_Destroy($hDataSource);
        $this->assertNull($hDataSource, "New data source is not NULL after".
                          " OGR_DS_Destroy()\n");
    }

    /*Opening an existing data source with MapInfo File driver*/
    function testOGR_Dr_Open1(){
        $hDriver = OGRGetDriver(5);
        $astrOptions[0] = "FORMAT=MIF";
  
        $hExistingDataSource =  OGR_Dr_Open($hDriver,
                                               $this->strPathToData.
                                               $this->strFilename,
                                               $this->bUpdate);

        $this->assertNotNull($hExistingDataSource, 
                             "Existing data source is NULL\n");
        OGR_DS_Destroy($hExistingDataSource);
        $this->assertNull($hExistingDataSource, 
                          "New data source is not NULL after".
                          " OGR_DS_Destroy()\n");

    }
    function testOGR_Dr_TestCapability1(){
        $hDriver = OGRGetDriver(5);
        $iCapability = OGR_Dr_TestCapability($hDriver, $this->strCapability);
        $this->assertTrue($iCapability,"Capability is supposed to be".
                          " supported" );
    }
}
?> <commit_msg>Modified class names.  Clarified messages in the Assert commands. Added a new test fixture for testOGR_Dr_GetName0(), testOGR_Dr_CreateDataSource(), testOGR_Dr_Open0() and testOGR_Dr_TestCapability0().  Added functionality to delete tmp working directory.  Added a test to verify a resource after execution of OGR_DS_Destroy().  Cleaned up.<commit_after><?php
//require_once 'phpunit-0.5/phpunit.php';
require_once("util.php");

class OGRSFDriverRegistrarTest3 extends PHPUnit_TestCase {
    var $strDirName;
    var $strPathToData;
    var $strPathToOutputData;
    var $strDestDataSource;
    var $bUpdate;
    var $hOGRSFDriver;
    var $strCapability;

    // constructor of the test suite
    function OGRSFDriverRegistrarTest3($name){
        $this->PHPUnit_TestCase($name);
    }
    // called before the test functions will be executed    
    // this function is defined in PHPUnit_TestCase and overwritten 
    // here
    function setUp() {
        $this->strDirName = "testcase/";
        $this->strPathToData = "./data/mif";
        $this->strPathToOutputData = "../../ogrtests/".$this->strDirName;
        $this->strDestDataSource = "OutputDS";
        $this->bUpdate = FALSE;
        $this->strCapability = ODrCCreateDataSource;


        if (file_exists($this->strPathToOutputData)) {
            system( "rm -R ".$this->strPathToOutputData);
        }

        mkdir($this->strPathToOutputData, 0777);

    }
    // called after the test functions are executed    
    // this function is defined in PHPUnit_TestCase and overwritten 
    // here    
    function tearDown() {
        // delete your instance
        unset($this->strDirName);
        unset($this->strPathToData);
        unset($this->strPathToOutputData);
        unset($this->strDestDataSource);
        unset($this->bUpdate);
        unset($this->strCapability);
        unset($this->hOGRSFDriver);
    }
/***********************************************************************
*                       testOGRGetDriverCount0()
*               Registered drivers supposed to be zero.
************************************************************************/

    function testOGRGetDriverCount0() {
        $nDriverCount = OGRGetDriverCount();

        $expected = 0;
        $this->assertEquals($expected, $nDriverCount, 
                            "Problem with OGRGetDriverCount():  ".
                            "Driver count is supposed".
                            " to be ".$expected, 0 /*$delta*/);
    }

/***********************************************************************
*                       testOGRGetDriverCount1()
*    Adding one driver.  PROBLEM WITH OGRGetDriver when no registered
*      driver exist.  TO COME BACK TO.
*
************************************************************************/

    function testOGRGetDriverCount1() {
        $hDriver = OGRGetDriver(0);

        $this->assertNull($result, "Problem with OGRGetDriver():  ".
                          "Return driver is supposed to be NULL".
                          "since no driver is registered.");
        $nDriverCount = OGRGetDriverCount();

        $expected = 0;
        $this->assertEquals($expected, $result, "Problem with ".
                            "OGRGetDriverCount():  Driver count is supposed".
                            " to be ".$expected." when no driver is ".
                            "registered.", 0 );
    }
/***********************************************************************
*                       testOGRGetDriverCount2()
*    Verify driver count with all drivers registered.
*
************************************************************************/
    function testOGRGetDriverCount2() {
        OGRRegisterAll();

        $nDriverCount = OGRGetDriverCount();

        $expected = 10;
        $this->assertEquals($expected, $nDriverCount, "Problem with ".
                            "OGRGetDriverCount():  Driver count is supposed".
                            " to be".$expected." after drivers are ".
                            "registered.", 0 /*$delta*/);
    }

/***********************************************************************
*                       testOGRGetDriverCount3()
*    Verify driver count after registering a new driver.
*    ERROR TO COME BACK TO.  OGRRegisterDriver seems to have 
*    no utility here.  hOGRSFDriver is not supposed to be null
*    after calling OGROpen().
*
************************************************************************/

    function testOGRGetDriverCount3() {

        $hDS = OGROpen($this->strPathToData, $this->bUpdate, 
                          $this->hOGRSFDriver);

        $this->assertNotNull($hDS, "Problem with ". 
                             "OGROpen():  data source handle is not ".
                             "supposed to be NULL.");

        $nDriverCount = OGRGetDriverCount();

        $expected = 0;
        $this->assertEquals($expected, $nDriverCount, 
                            "Problem with OGRGetDriverCount():  ".
                            "Driver count is supposed".
                            " to be ".$expected." before registering ".
                            "a new driver.", 0 /*$delta*/);
        @OGRRegisterDriver($this->hOGRSFDriver);
        $nDriverCount = OGRGetDriverCount();

        $expected = 1;
        $this->assertEquals($expected, $nDriverCount, "Problem with ".
                            "OGRRegisterDriver():  Driver count is supposed".
                            " to be ".$expected." after a new driver is ".
                            "registered.", 0 /*$delta*/);
    }

/***********************************************************************
*                       testOGRGetDriver0()
*       Get a driver handle after execution OGRRegisterAll().
************************************************************************/
    function testOGRGetDriver0() {
        OGRRegisterAll();

        $hDriver = OGRGetDriver(0);

        $this->assertNotNull($hDriver, "Problem with OGRGetDriver():".
                             "Driver is not supposed".
                            " to be NULL");
    }
/***********************************************************************
*                       testOGRGetDriver1()
*               Getting a driver with an id out of range.
************************************************************************/

    function testOGRGetDriver1() {
        OGRRegisterAll();

        $hDriver = OGRGetDriver(50);

        $this->assertNull($hDriver, "Problem with OGRGetDriver():  ".
                          "driver handle is supposed".
                          " to be NULL since requested driver ".
                          "is out of range.");
    }
/***********************************************************************
*                       testOGRRegisterDriver0()
*               Adding an existing driver has no effect.
************************************************************************/

    function testOGRRegisterDriver0() {
        OGRRegisterAll();

        $hDriver = OGRGetDriver(2);

        $this->assertNotNull($hDriver, "Problem with OGRGetDriver():  ".
                             "driver handle is not supposed".
                             " to be NULL.");
        OGRRegisterDriver($hDriver);
        $nDriverCount = OGRGetDriverCount();

        $expected = 10;
        $this->assertEquals($expected, $nDriverCount, "Problem with ".
                            "OGRRegisterDriver():  driver count is ".
                            "supposed to be ".$expected." since this ".
                            "driver is already registered.", 0 /*$delta*/);
    }
}

class OGRSFDriverTest0 extends PHPUnit_TestCase {
    var $strDirName;
    var $strPathToData;
    var $strPathToOutputData;
    var $strDestDataSource;
    var $bUpdate;
    var $hOGRSFDriver;
    var $strCapability;

    // constructor of the test suite
    function OGRSFDriverTest0($name){
        $this->PHPUnit_TestCase($name);
    }
    // called before the test functions will be executed    
    // this function is defined in PHPUnit_TestCase and overwritten 
    // here
    function setUp() {
        $this->strDirName = "testcase/";
        $this->strPathToData = "./data/mif";
        $this->strPathToOutputData = "../../ogrtests/".$this->strDirName;
        $this->strDestDataSource = "OutputDS";
        $this->bUpdate = FALSE;
        $this->strCapability = ODrCCreateDataSource;


        if (file_exists($this->strPathToOutputData)) {
            system( "rm -R ".$this->strPathToOutputData);
        }

        mkdir($this->strPathToOutputData, 0777);

    }
    // called after the test functions are executed    
    // this function is defined in PHPUnit_TestCase and overwritten 
    // here    
    function tearDown() {
        // delete your instance
        unset($this->strDirName);
        unset($this->strPathToData);
        unset($this->strPathToOutputData);
        unset($this->strDestDataSource);
        unset($this->bUpdate);
        unset($this->strCapability);
        unset($this->hOGRSFDriver);
    }

/***********************************************************************
*                       testOGR_Dr_GetName0()
*                       Getting driver name.
************************************************************************/

    function testOGR_Dr_GetName0() {
        OGRRegisterAll();						-

        $hDriver = OGRGetDriver(7);
        $strDriverName = OGR_Dr_GetName($hDriver);

        $expected = "GML";
        $this->assertEquals($expected, $strDriverName, "Problem with ".
                            "OGR_Dr_GetName():  Driver name is not".
                            "corresponding to what is expected.\n");
    }

/***********************************************************************
*               testOGR_Dr_CreateDataSource0()
*       Creating a data source with MapInfo File driver.
************************************************************************/

    function testOGR_Dr_CreateDataSource0(){

        OGRRegisterAll();

        $hDriver = OGRGetDriver(5);
        $astrOptions[0] = "FORMAT=MIF";

        $hDataSource = OGR_Dr_CreateDataSource($hDriver, 
                                               $this->strPathToOutputData.
                                               $this->strDestDataSource,
                                               $astrOptions );

        $this->assertNotNull($hDataSource, "Problem with ".
                             "OGR_Dr_CreateDataSource():  ".
                             "New data source is not supposed to be NULL.");


        OGR_DS_Destroy($hDataSource);

        $expected = "Unknown";

        $actual = get_resource_type($hDataSource);


        $this->assertEquals($expected, $actual, "Problem with ".
                          "OGR_DS_Destroy():  ".
                          "Data source resource is supposed to be freed ".
                          "after OGR_DS_Destroy().");
    }

/***********************************************************************
*                        testOGR_Dr_Open0()
*       Opening an existing data source with MapInfo File driver.
************************************************************************/


    function testOGR_Dr_Open0(){
        OGRRegisterAll();

        $this->hOGRSFDriver = OGRGetDriver(5);
        $astrOptions[0] = "FORMAT=MIF";
  
        $hSrcDataSource =  OGR_Dr_Open($this->hOGRSFDriver,
                                       $this->strPathToData,
                                       $this->bUpdate);

        $this->assertNotNull($hSrcDataSource, 
                             "Problem with OGR_Dr_Open():  ".
                             "handle to existing data source is not ".
                             "supposed to be NULL.");
        OGR_DS_Destroy($hSrcDataSource);
    }

/***********************************************************************
*                        testOGR_Dr_TestCapability0()
************************************************************************/

    function testOGR_Dr_TestCapability0(){

        OGRRegisterAll();

        $this->hOGRSFDriver = OGRGetDriver(5);
        $bCapability = OGR_Dr_TestCapability($this->hOGRSFDriver, 
                                             $this->strCapability);
        $this->assertTrue($bCapability,"Problem with ".
                          "OGR_Dr_TestCapability():  ".$this->strCapability.
                          " is supposed to be".
                          " supported." );
    }
}
?> 
{'fraction_non_alphanumeric': 0.1850263010060773, 'fraction_numerical': 0.005413410959603697, 'mean_word_length': 2.041155458922193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4031853', 'n_tokens_mistral': 5141, 'n_tokens_neox': 4916, 'n_words': 1156}