<commit_before><?php
/**
 * MongoModel
 *
 * Copyright (C) 2011 <NAME>
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright (C) 2011 <NAME>
 * @package mongo_model
 * @license The MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

use \mongo_model\ConnectionManager;
use \mongo_model\embedded\Many;

class ManyTest extends \PHPUnit_Framework_TestCase {

	public function testFromMongoData() {
		$data = array(
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'James', 'message' => 'Hello'),
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'Armaan', 'message' => 'Hello')
		);

		$result = Many::fromMongoData(new MockPost, 'mock_comments', $data);

		$this->assertInstanceOf('\mongo_model\embedded\Many', $result);
		$this->assertEquals(2, count($result));
		$this->assertInstanceOf('\MockComment', $result[0]);
		$this->assertInstanceOf('\MockComment', $result[1]);
	}

	public function testSerializeForSaving() {
		$data = array(
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'James', 'message' => 'Hello'),
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'Armaan', 'message' => 'Hello')
		);

		$collection = Many::fromMongoData(new MockPost, 'mock_comments', $data);
		$result = $collection->serializeForSaving();

		$this->assertEquals($data, $result);
	}
}<commit_msg>test for serializeForSaving() without IDs<commit_after><?php
/**
 * MongoModel
 *
 * Copyright (C) 2011 <NAME>
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright (C) 2011 <NAME>
 * @package mongo_model
 * @license The MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

use \mongo_model\ConnectionManager;
use \mongo_model\embedded\Many;

class ManyTest extends \PHPUnit_Framework_TestCase {

	public function testFromMongoData() {
		$data = array(
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'James', 'body' => 'Hello'),
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'Armaan', 'body' => 'Hello')
		);

		$result = Many::fromMongoData(new MockPost, 'mock_comments', $data);

		$this->assertInstanceOf('\mongo_model\embedded\Many', $result);
		$this->assertEquals(2, count($result));
		$this->assertInstanceOf('\MockComment', $result[0]);
		$this->assertInstanceOf('\MockComment', $result[1]);
	}

	public function testSerializeForSaving() {
		$data = array(
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'James', 'body' => 'Hello'),
			array('_id' => new \MongoId('4e74f5554cfb452b6e000000'), 'author' => 'Armaan', 'body' => 'Hello')
		);

		$collection = Many::fromMongoData(new MockPost, 'mock_comments', $data);
		$result = $collection->serializeForSaving();

		$this->assertEquals($data, $result);
	}

	public function testSerializeForSavingWithoutIds() {
		$collection = new Many(new MockPost, array());
		$collection[] = new MockComment(array('author' => 'James', 'body' => 'Hello'));

		$result = $collection->serializeForSaving();
		$this->assertInstanceOf('\MongoId', $result[0]['_id']);
	}
}
{'fraction_non_alphanumeric': 0.1806709756848261, 'fraction_numerical': 0.048938134810710986, 'mean_word_length': 5.513026052104208, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1861713', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1105, 'n_words': 222}