Example #1
0
 public function test_setAllBlockRows()
 {
     $x = new Template(__DIR__ . '/files/templates/mainWithBlockRow.tmpl');
     $allDefs = $x->get_block_row_defs();
     $allRows = $x->setAllBlockRows();
     $this->assertEquals(count($allDefs), count($allRows), "did not get equal lists of rows from get vs set");
     foreach ($allDefs as $testRowName) {
         $this->assertTrue(isset($allRows[$testRowName]), "could not find definition for row '" . $testRowName . "' in list of all rows");
     }
     $this->assertEquals(1, count($allRows), "invalid number of block rows found");
     $this->assertTrue(isset($allRows['test']), "could not find block row 'test'");
     $rowsFromObject = $x->blockRows;
     $this->assertTrue(is_array($rowsFromObject));
     $this->assertEquals(1, count($rowsFromObject));
     $this->assertEquals($allRows, $rowsFromObject, "rows returned does not match rows in object");
     $recordSet = array(0 => array("var1" => "1", "var2" => "2", "var3" => "3"), 1 => array("var1" => "x4", "var2" => "x5", "var3" => "x6"));
     $checkThis = $x->parseBlockRow("test", $recordSet);
     $this->assertTrue(strlen($checkThis) > 0, "no length in parsed row (" . $checkThis . ")");
     $this->assertEquals(0, strpos($checkThis, '1 2 3'), "could not find parsed values... '" . $checkThis . "'");
     $this->assertEquals(6, strpos($checkThis, 'x4 x5 x6'), "could not find second set of parsed values... '" . $checkThis . "'");
 }