Beispiel #1
0
    public function testCSSColumnClasses()
    {
        $obj = new ExportData();
        $obj->add('Vivid Color', 'orange')->add('Definitive_SHAPE', 'rectangle');
        $export = new HTMLExporter($obj);
        $control = '<table>
<thead>
<tr><td class="colgroup-vivid-color">Vivid Color</th><td class="colgroup-definitive-shape">Definitive_SHAPE</th></tr>
</thead>
<tbody>
<tr><td class="colgroup-vivid-color">orange</td><td class="colgroup-definitive-shape">rectangle</td></tr>
</tbody>
</table>
';
        $this->assertSame($control, $export->export());
    }
Beispiel #2
0
 public function testLocations()
 {
     $obj = $this->obj;
     // This is null because page 2 doesn't have a Name column
     $this->assertNull($obj->getCurrent('Name'));
     // This is null because we're on row 2
     $this->assertNull($obj->getCurrent('Color'));
     $return = $obj->setPointer(1)->getCurrent('Color');
     $this->assertSame('White', $return);
     $obj->storeLocation('cars');
     $return = $obj->gotoLocation('start');
     $this->assertInstanceOf('AKlump\\LoftDataGrids\\ExportData', $return);
     $this->assertSame('Hillary', $obj->getCurrent('Name'));
     $this->assertEquals(0, $obj->getCurrentPageId());
     $this->assertEquals(1, $obj->getPointer());
     $subject = array('start' => array('page' => 0, 'pointers' => array(0 => 1, 1 => 0)), 'cars' => array('page' => 1, 'pointers' => array(0 => 1, 1 => 1)));
     $this->assertSame($subject, $locs = $obj->getLocations());
     $copy = new ExportData();
     $copy->setLocations($locs);
     $this->assertSame($subject, $copy->getLocations());
 }
    function testExport()
    {
        $data = new ExportData();
        $data->setPage('Notes of the Scale');
        $data->add('do', 'C');
        $data->add('re re re', 'D');
        $data->add('mi miiiiii', 'E')->next();
        $data->add('do', 'D');
        $data->add('re re re', 'E');
        $data->add('mi miiiiii', 'F#')->next();
        $obj = new FlatTextExporter($data);
        $control = <<<EOD
------------------------------
| DO | RE RE RE | MI MIIIIII |
------------------------------
| C  | D        | E          |
------------------------------
| D  | E        | F#         |
------------------------------

EOD;
        $this->assertSame($control, $obj->export());
        $control = <<<EOD
-- NOTES OF THE SCALE --
------------------------------
| DO | RE RE RE | MI MIIIIII |
------------------------------
| C  | D        | E          |
------------------------------
| D  | E        | F#         |
------------------------------

EOD;
        $this->assertSame($control, $obj->showPageIds()->export());
        $control = <<<EOD
------------------------------
| DO | RE RE RE | MI MIIIIII |
------------------------------
| C  | D        | E          |
------------------------------
| D  | E        | F#         |
------------------------------

EOD;
        $this->assertSame($control, $obj->hidePageIds()->export());
    }
    function testExport()
    {
        $data = new ExportData('Notes of the Scale');
        $data->add('do', 'C');
        $data->add('re re re', 'D');
        $data->add('mi miiiiii', 'E')->next();
        $data->add('do', 'D');
        $data->add('re re re', 'E');
        $data->add('mi miiiiii', 'F#')->next();
        $obj = new MarkdownTableExporter($data);
        $control = <<<EOD
## Notes of the Scale
| do | re re re | mi miiiiii |
|----|----------|------------|
| C  | D        | E          |
| D  | E        | F#         |

EOD;
        $this->assertSame($control, $obj->export());
        $control = <<<EOD
| do | re re re | mi miiiiii |
|----|----------|------------|
| C  | D        | E          |
| D  | E        | F#         |

EOD;
        $this->assertSame($control, $obj->hidePageIds()->export());
        $control = <<<EOD
## Notes of the Scale
| do | re re re | mi miiiiii |
|----|----------|------------|
| C  | D        | E          |
| D  | E        | F#         |

EOD;
        $this->assertSame($control, $obj->showPageIds()->export());
    }
 public function testKeys()
 {
     /**
      * Assert setting the keys as an array populates the first row
      */
     $_control_group = 'ExportData::setKeys';
     // Desired test result
     $control = array('do', 're', 'mi', 'fa');
     // The test and result
     $object = new ExportData();
     $return = $object->setKeys($control);
     $object->add('do', 'C');
     $return = $object->getCurrent();
     $result = array_keys($return);
     $this->assertIdentical($control, $result, "Assert setting the keys populates the first row", $_control_group);
     // END ASSERT
     /**
      * Assert setting the keys as arguments populates the first row
      */
     $_control_group = 'ExportData::setKeys';
     // Desired test result
     $control = array('do', 're', 'mi', 'fa');
     // The test and result
     $object = new ExportData();
     $return = $object->setKeys('do', 're', 'mi', 'fa');
     $object->add('mi', 'E');
     $return = $object->getCurrent();
     $result = array_keys($return);
     $this->assertIdentical($control, $result, "Assert setting the keys populates the first row", $_control_group);
     // Assert setting the keys after data exists modifies the order of data returned by get
     $control = array('fa', 'mi', 're', 'do');
     $object->setKeys($control);
     $return = $object->getCurrent();
     $result = array_keys($return);
     $this->assertIdentical($control, $result, "Assert setting the keys after data exists modifies the order of data returned by get", $_control_group);
     // Assert getCurrentPageId
     $control = 0;
     $result = $object->getCurrentPageId();
     $this->assertIdentical($control, $result, "Assert getCurrentPageId", $_control_group);
     // Assert get current page id returns after switching pages
     $control = 'my_next_page';
     $object->setPage($control);
     $result = $object->getCurrentPageId();
     $this->assertIdentical($control, $result, "Assert get current page id returns after switching pages", $_control_group);
     // END ASSERT
 }
Beispiel #6
0
 public function getData()
 {
     // @todo I feel like this is a really bloated way of doing this
     // by creating a new object, etc.  Maybe we can do t his differnetly...
     // We pause our locations so that our iterations don't mess with things,
     // we'll later resume below.
     $this->export_data->storeLocation('getData');
     $locations = $this->export_data->getLocations();
     // Sort the data into the correct order based on the header
     $pages = $this->export_data->get();
     $temp = new ExportData();
     foreach ($pages as $page_id => $data) {
         $temp->setPage($page_id);
         $header = $this->getHeader($page_id);
         foreach ($data as $d) {
             foreach (array_keys($header) as $key) {
                 $temp->add($key, $d[$key]);
             }
             $temp->next();
         }
     }
     $this->setData($temp);
     $this->export_data->setLocations($locations);
     $this->export_data->gotoLocation('getData');
     return $this->export_data;
 }
Beispiel #7
0
      } else if (result < 0) {
        $("<span/>").text("<?php 
        echo $GLOBALS['locPrereleaseVersion'];
        ?>
").appendTo("#version");
      }
      $.cookie("updateversion", $.toJSON(data), { expires: 1 });
    }
  </script>
<?php 
    }
}
if ($strFunc == 'system' && getRequest('operation', '') == 'export' && sesAdminAccess()) {
    createFuncMenu($strFunc);
    require_once 'export.php';
    $export = new ExportData();
    $export->launch();
} elseif ($strFunc == 'system' && getRequest('operation', '') == 'import' && sesAdminAccess()) {
    createFuncMenu($strFunc);
    require_once 'import.php';
    $import = new ImportFile();
    $import->launch();
} elseif ($strFunc == 'import_statement') {
    createFuncMenu($strFunc);
    require_once 'import_statement.php';
    $import = new ImportStatement();
    $import->launch();
} else {
    switch ($strFunc) {
        case 'reports':
            createFuncMenu($strFunc);
 public function testGetValue()
 {
     $obj = new ExportData();
     $obj->add('Name', 'Aaron')->add('Age', 39)->next();
     $obj->add('Name', 'Hillary')->add('Age', 37)->next();
     $obj->add('Name', 'Maia')->add('Age', 7)->next();
     $obj->setPage(1);
     $obj->add('Color', 'Black')->add('Make', 'Subaru')->next();
     $obj->add('Color', 'White')->add('Make', 'Hyundai')->next();
     $return = $obj->setPage(0)->setPointer(0)->getValue('Age');
     $this->assertSame(39, $return);
     $return = $obj->setPage(0)->getValue('Name');
     $this->assertSame('Aaron', $return);
     $return = $obj->setPage(1)->setPointer(0)->getValue('Color');
     $this->assertSame('Black', $return);
     $return = $obj->getValue('Make');
     $this->assertSame('Subaru', $return);
 }