<commit_before><?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

require_once('lib/webmail/tikimaillib.php');

class Reports_SendTest extends TikiTestCase
{
	protected $obj;
	
	protected $dt;
	
	protected function setUp()
	{
		$this->dt = new DateTime;
		$this->dt->setTimestamp(strtotime('2012-03-27 15:55:16'));
		
		$this->mail = $this->createMock('TikiMail');
		$this->builder = $this->getMockBuilder('Reports_Send_EmailBuilder')->disableOriginalConstructor()->getMock();
		
		$tikiPrefs = array('short_date_format' => '%Y-%m-%d', 'browsertitle' => 'test');
		
		$this->obj = new Reports_Send($this->dt, $this->mail, $this->builder, $tikiPrefs);
	}
	
	public function testEmailSubject_noChanges()
	{
		$this->mail->expects($this->exactly(2))->method('setSubject')->with('Report on test from 2012-03-27 (no changes)');
		
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		
		$this->obj->sendEmail($userData, $reportPreferences, array());
		$this->obj->sendEmail($userData, $reportPreferences, '');
	}
	
	public function testEmailSubject_oneChange()
	{
		$this->mail->expects($this->exactly(1))->method('setSubject')->with('Report on test from 2012-03-27 (1 change)');
		
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		
		$this->obj->sendEmail($userData, $reportPreferences, array(1));
	}
	
	public function testEmailSubject_multipleChanges()
	{
		$this->mail->expects($this->exactly(1))->method('setSubject')->with('Report on test from 2012-03-27 (2 changes)');
		
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		
		$this->obj->sendEmail($userData, $reportPreferences, array(1, 2));
	}
	
	public function testSendEmail()
	{
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		$reportCache = array();
		$emailBody = 'body';
		
		$this->builder->expects($this->once())->method('emailBody')
			->with($userData, $reportPreferences, $reportCache)->will($this->returnValue($emailBody));
		$this->mail->expects($this->once())->method('setUser')->with('test');
		$this->mail->expects($this->once())->method('setHtml')->with($emailBody);
		$this->mail->expects($this->once())->method('setSubject')->with('Report on test from 2012-03-27 (no changes)');
		$this->mail->expects($this->once())->method('send')->with(array('<EMAIL>'));
		
		$this->obj->sendEmail($userData, $reportPreferences, $reportCache);
	}
}<commit_msg>[FIX] tests: Fixed some reports tests - updated whitespace changes in output<commit_after><?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

require_once('lib/webmail/tikimaillib.php');

class Reports_SendTest extends TikiTestCase
{
	protected $obj;
	
	protected $dt;
	
	protected function setUp()
	{
		$this->dt = new DateTime;
		$this->dt->setTimestamp(strtotime('2012-03-27 15:55:16'));
		
		$this->mail = $this->createMock('TikiMail');
		$this->builder = $this->getMockBuilder('Reports_Send_EmailBuilder')->disableOriginalConstructor()->getMock();
		
		$tikiPrefs = array('short_date_format' => '%Y-%m-%d', 'browsertitle' => 'test');
		
		$this->obj = new Reports_Send($this->dt, $this->mail, $this->builder, $tikiPrefs);
	}
	
	public function testEmailSubject_noChanges()
	{
		$this->mail->expects($this->exactly(2))->method('setSubject')->with('Report on test from 2012-03-27 (no changes)');
		
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		
		$this->obj->sendEmail($userData, $reportPreferences, array());
		$this->obj->sendEmail($userData, $reportPreferences, '');
	}
	
	public function testEmailSubject_oneChange()
	{
		$this->mail->expects($this->exactly(1))->method('setSubject')->with('Report on test from 2012-03-27 (1 change)');
		
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		
		$this->obj->sendEmail($userData, $reportPreferences, array(1));
	}
	
	public function testEmailSubject_multipleChanges()
	{
		$this->mail->expects($this->exactly(1))->method('setSubject')->with('Report on test from 2012-03-27 (2 changes)');
		
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		
		$this->obj->sendEmail($userData, $reportPreferences, array(1, 2));
	}
	
	public function testSendEmail()
	{
		$userData = array('login' => 'test', 'email' => '<EMAIL>');
		$reportPreferences = array('type' => 'html');
		$reportCache = array();
		$emailBody = 'body';
		
		$this->builder->expects($this->once())->method('emailBody')
			->with($userData, $reportPreferences, $reportCache)->will($this->returnValue($emailBody));
		$this->mail->expects($this->once())->method('setUser')->with('test');
		$this->mail->expects($this->once())->method('setHtml')->with($emailBody);
		$this->mail->expects($this->once())->method('setSubject')->with('Report on test from 2012-03-27 (no changes)');
		$this->mail->expects($this->once())->method('send')->with(array('<EMAIL>'));
		
		$this->obj->sendEmail($userData, $reportPreferences, $reportCache);
	}
}
{'fraction_non_alphanumeric': 0.2109749600426212, 'fraction_numerical': 0.022020955425324097, 'mean_word_length': 5.335208098987627, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 171, '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': '6699926', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1799, 'n_words': 348}