<commit_before><?php

namespace li3_fake_model\tests\cases\extensions\data;

use li3_fake_model\tests\mocks\extensions\data\MockModel;
use li3_fake_model\tests\mocks\extensions\data\MockChildModel;
use li3_fake_model\tests\mocks\extensions\data\MockGrandchildModel;
use li3_fake_model\tests\mocks\extensions\data\MockRealModel;
use li3_fake_model\tests\mocks\extensions\data\MockDogModel;
use li3_fake_model\extensions\test\Unit;

use lithium\data\Connections;

class ModelTest extends Unit {

	public function setUp() {
		$this->child = MockChildModel::create(array(
			'level'     => 2,
		));
		$this->child->save();
		$this->dog = MockDogModel::create(array(
			'name'     => 'Fido',
		));
		$this->dog->save();
		$this->grandchild = MockGrandchildModel::create(array(
			'level'     => 3,
			'parent_id' => $this->child->_id,
			'dog_id' => $this->dog->_id,
		));
		$this->grandchild->save();
		$this->parent = MockModel::create(array(
			'level'     => 1,
			'child_ids' => array(
				$this->child->_id,
			),
		));
		$this->parent->save();

		$this->db = Connections::get('default')->connection;
	}

	public function tearDown() {
		$connection = Connections::get('default');
		if(!preg_match('/_test$/', $connection->_config['database'])) {
			throw new RuntimeException('test database not configured!');
		}
		$mongo = $connection->connection;
		foreach($mongo->listCollections() as $collection) {
			$collection->drop();
		}
	}<commit_msg>Fix exception.<commit_after><?php

namespace li3_fake_model\tests\cases\extensions\data;

use li3_fake_model\tests\mocks\extensions\data\MockModel;
use li3_fake_model\tests\mocks\extensions\data\MockChildModel;
use li3_fake_model\tests\mocks\extensions\data\MockGrandchildModel;
use li3_fake_model\tests\mocks\extensions\data\MockRealModel;
use li3_fake_model\tests\mocks\extensions\data\MockDogModel;
use li3_fake_model\extensions\test\Unit;

use lithium\data\Connections;

class ModelTest extends Unit {

	public function setUp() {
		$this->child = MockChildModel::create(array(
			'level'     => 2,
		));
		$this->child->save();
		$this->dog = MockDogModel::create(array(
			'name'     => 'Fido',
		));
		$this->dog->save();
		$this->grandchild = MockGrandchildModel::create(array(
			'level'     => 3,
			'parent_id' => $this->child->_id,
			'dog_id' => $this->dog->_id,
		));
		$this->grandchild->save();
		$this->parent = MockModel::create(array(
			'level'     => 1,
			'child_ids' => array(
				$this->child->_id,
			),
		));
		$this->parent->save();

		$this->db = Connections::get('default')->connection;
	}

	public function tearDown() {
		$connection = Connections::get('default');
		if(!preg_match('/_test$/', $connection->_config['database'])) {
			throw new \RuntimeException('test database not configured!');
		}
		$mongo = $connection->connection;
		foreach($mongo->listCollections() as $collection) {
			$collection->drop();
		}
	}
{'fraction_non_alphanumeric': 0.1781767955801105, 'fraction_numerical': 0.006906077348066298, 'mean_word_length': 4.571153846153846, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3388295', 'n_tokens_mistral': 1101, 'n_tokens_neox': 991, 'n_words': 145}