/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { // set up our object $dom = new Vci_Dom_Document(); $dom->loadHTML($this->table); $table = $dom->query('//table'); $table = $table->item(0); $table = new Vci_Dom_Table($table); $this->object = $table[0]; $this->object->setHeaders($this->headers); $this->object1 = $table[1]; $this->object1->setHeaders($this->headers); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { // V1 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV1); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV1 = new Vci_Dom_Table($table); // V2 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV2); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV2 = new Vci_Dom_Table($table); // V3 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV3); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV3 = new Vci_Dom_Table($table); // V4 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV4); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV4 = new Vci_Dom_Table($table); // V5 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV5); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV5 = new Vci_Dom_Table($table); // V6 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV6); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV6 = new Vci_Dom_Table($table); // V7 $dom = new Vci_Dom_Document(); $dom->loadHTML($this->tableV7); $table = $dom->query('//table'); $table = $table->item(0); $this->objectV7 = new Vci_Dom_Table($table); // set up the tablesData array $this->tablesData = array(array('object' => $this->objectV1, 'headers' => $this->headersV1, 'name' => 'V1'), array('object' => $this->objectV2, 'headers' => $this->headersV2, 'name' => 'V2'), array('object' => $this->objectV3, 'headers' => $this->headersV3, 'name' => 'V3'), array('object' => $this->objectV4, 'headers' => $this->headersV4, 'name' => 'V4'), array('object' => $this->objectV5, 'headers' => $this->headersV5, 'name' => 'V5'), array('object' => $this->objectV6, 'headers' => $this->headersV6, 'name' => 'V6'), array('object' => $this->objectV7, 'headers' => $this->headersV7, 'name' => 'V7')); }
/** * Shortcut function for creating a DOM Table object * * @param Vci_Dom_Document $dom * The dom document that we are operating on * @param string $xpath * An xpath to the table we want to access * @param array $headers * Any headers describing the table structure (see __construct()) * @param DOMNode $reference * A reference node to run the xpath relative to * @return A new DOM Table object, else false * @author "David Hazel" <*****@*****.**> **/ public function factory(Vci_Dom_Document $dom, $xpath, $headers = null, DOMNode $reference = null) { // resolve the xpath to a single table node $table = $dom->query($xpath, $reference); // check for extraction failure $table = $table->item(0); if (empty($table)) { throw new Exception('The xpath, "' . $xpath . '", did not resolve to any valid DOM Nodes.'); } // instantiate a table object for the table return new self($table, $headers); }