Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
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());
    }
Ejemplo n.º 3
0
    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
 }
Ejemplo n.º 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;
 }