lithium\test\Fixture::_create()

public method

Create the fixture's schema and import records.

Parameters

  • boolean $drop

    If true drop the fixture before creating it

  • boolean $load

    If true load fixture's records

Returns

boolean

True on success, false on failure

Source

	public function _create($drop = true, $save = true) {
		$connections = $this->_classes['connections'];
		$db = $connections::get($this->_connection);

		if ($drop && !$this->drop()) {
			return false;
		}

		$this->_alteredFields = $this->_alterFields($this->_fields);
		$return = true;

		if ($db::enabled('schema')) {
			$schema = Libraries::instance(null, 'schema', [
				'fields' => $this->_alteredFields,
				'meta' => $this->_meta,
				'locked' => $this->_locked
			], $this->_classes);

			$return = $db->createSchema($this->_source, $schema);
		}

		if ($return && $save) {
			foreach ($this->_records as $record) {
				if (!$this->populate($record, true)) {
					return false;
				}
			}
		}
		return $return;
	}