Esempio n. 1
0
 protected function setUp()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     $db->execute(file_get_contents(DB_SETUP_FILE));
     $this->sharedFixture = array('db' => $db, 'schema' => fJSON::decode(file_get_contents(DB_SCHEMA_FILE), TRUE));
 }
 public static function setUpBeforeClass()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     $db->execute(file_get_contents(DB_SETUP_FILE));
     self::$db = $db;
     self::$json_schema = fJSON::decode(file_get_contents(DB_SCHEMA_FILE), TRUE);
 }
     Good_receipt_note_detail::deleteDetail($_POST['key']);
 } else {
     if ($_POST['type'] == "json") {
         $grn_details = Good_receipt_note_detail::findDetail($_POST['key']);
         echo $grn_details->toJSON();
     } else {
         if ($_POST['type'] == "save") {
             try {
                 $grn = new Good_receipt_note($_POST['doc_number']);
                 $grn->populate();
                 if (!$error) {
                     $grn->store();
                 }
                 if ($_POST['jsonForm'] != "") {
                     $json_form = fRequest::get('jsonForm');
                     $jsonForm = fJSON::decode($json_form);
                     foreach ($jsonForm as $row) {
                         try {
                             $grn_detail = new Good_receipt_note_detail();
                             $grn_detail->setDocNumber($_POST['doc_number']);
                             $grn_detail->setItemId($row->{'itemCode'});
                             $grn_detail->setDescription($row->{'itemDesc'});
                             $grn_detail->setQuantity($row->{'itemQuan'});
                             $grn_detail->setAssessment($row->{'assess'});
                             $grn_detail->setRemark($row->{'remarks'});
                             if (!$error) {
                                 $grn_detail->store();
                             }
                         } catch (fExpectedException $e) {
                             echo $e->printMessage();
                             $error = true;
Esempio n. 4
0
 /**
  * Loads a fixture and makes the fixture data accessible through $this->fixture_data.
  *
  * @param string $fixture_name
  *   Name of the fixture to load.
  * @return Returns the loaded fixture data or NULL in the case that there was no source for the requested fixture. Note that if fill mode is off exceptions are thrown in stead of returning NULL.
  */
 private function loadFixture($fixture_name)
 {
     if (isset($this->fixture_data[$fixture_name])) {
         return $this->fixture_data[$fixture_name];
     }
     if (isset($this->fixture_sources[$fixture_name]) === FALSE) {
         //if ($this->fill_mode === FALSE) {
         throw new fValidationException("There exists no fixtures for, %s", $fixture_name);
         //}
         return NULL;
     }
     $fixture_source = $this->fixture_sources[$fixture_name];
     // Helper vars
     $fixture = $this;
     $now = date('Y-m-d H:i:s');
     $a_moment_ago = date('Y-m-d H:i:s', strtotime('-5 minutes'));
     $in_a_moment_ago = date('Y-m-d H:i:s', strtotime('+5 minutes'));
     // Source is a JSON fixture file
     if ($fixture_source instanceof fFile) {
         // Grab the content from buffer
         ob_start();
         require $fixture_source->getPath();
         $json_data = ob_get_clean();
         // Decode
         $fixture_data = fJSON::decode($json_data);
         if (empty($fixture_data)) {
             throw new fValidationException("Invalid fixture file, %s", $fixture_source->getPath());
         }
         $this->fixture_data[$fixture_name] = $fixture_data;
     } else {
         if ($fixture_source instanceof fFixtureSeed) {
             // Source is a fFixtureSeed
         }
     }
 }
Esempio n. 5
0
    public function testDecodeObjectToAssoc()
    {
        $output = fJSON::decode('{
				 "level1_key1": {
					 "level2_key1": {
						 "level3_key1": true,
						 "level3_key2": false
					 },
					 "level2_key2": {
						 "level3_key3": true,
						 "level3_key4": false,
						 "level3_key5": null
					 }
				 }
			 }', TRUE);
        $expected = array('level1_key1' => array('level2_key1' => array('level3_key1' => TRUE, 'level3_key2' => FALSE), 'level2_key2' => array('level3_key3' => TRUE, 'level3_key4' => FALSE, 'level3_key5' => NULL)));
        $this->assertEquals($expected, $output);
    }