Commit 907f54f2 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Update Unit Tests.

parent 8b437984
......@@ -1073,60 +1073,6 @@ EOF;
}
public function testSendmailConvertToken() {
// Minimal setup
$result = $this->report->sendmailConvertToken('');
$expect = [''];
$this->assertEquals($expect, $result);
// Simple 'fixed position' DEPRECATED - not sure if it's ok that the array is not fillled up to the maximum.
$result = $this->report->sendmailConvertToken('john@doe.com|jane@miller.com|Latest|Dear John');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John'];
$this->assertEquals($expect, $result);
// Simple 'token based'
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', '', '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// All (but attachment) 'token based'
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|r:reply@doe.com|A:on|g:123|x:234|c:july@doe.com,steve@doe.com|B:ceo@doe.com|h:Auto-Submit: fake|y:345|z:456|S:test.php');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', 'reply@doe.com', 'on', '123', '234', 'july@doe.com,steve@doe.com', 'ceo@doe.com', '', 'Auto-Submit: fake', '345', '456', 'test.php', '', ''];
$this->assertEquals($expect, $result);
// Single attachment 'token based'
$attach = [['F:fileadmin/test1.pdf']];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// Three individual attachment 'token based'
// $attach = [ [ [ 'F' => 'fileadmin/test1.pdf' ], [ 'F' => 'fileadmin/test2.pdf' ], [ 'F' => 'fileadmin/test3.pdf' ] ] ] ;
$attach = [['F:fileadmin/test1.pdf'], ['F:fileadmin/test2.pdf'], ['F:fileadmin/test3.pdf']];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// One individual attachment, one dual combined attachment
$attach = [['F:fileadmin/test1.pdf'], ['F:fileadmin/test2.pdf', 'F:fileadmin/test3.pdf']];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|C|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// One individual attachment, one quad combined attachment
$attach = [['F:fileadmin/test1.pdf'], ['F:fileadmin/test2.pdf', 'F:fileadmin/test3.pdf', 'u:http://nzz.ch', 'U:export&a=100']];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|C|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf|u:http://nzz.ch|U:export&a=100');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// Two quad combined attachments
$attach = [['d:output1.pdf', 'F:fileadmin/test11.pdf', 'F:fileadmin/test12.pdf', 'u:http://nzz.ch.1', 'U:export1&a=100'], ['d:output2.pdf', 'F:fileadmin/test21.pdf', 'F:fileadmin/test22.pdf', 'u:http://nzz.ch.2', 'U:export2&a=100']];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|C|d:output1.pdf|F:fileadmin/test11.pdf|F:fileadmin/test12.pdf|u:http://nzz.ch.1|U:export1&a=100|C|d:output2.pdf|F:fileadmin/test21.pdf|F:fileadmin/test22.pdf|u:http://nzz.ch.2|U:export2&a=100');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
}
/**
*
......
<?php
namespace qfq;
use qfq;
require_once(__DIR__ . '/../../qfq/report/SendMail.php');
/**
* Created by PhpStorm.
* User: crose
* Date: 2/2/16
* Time: 10:07 PM
*/
class SendMailTest extends \PHPUnit_Framework_TestCase {
/**
* @var qfq\SendMail
*/
private $sendMail = null;
public function parseStringToArray() {
$this->sendMail = new SendMail();
// Minimal setup
$result = $this->sendMail->parseStringToArray('');
$expect = [''];
$this->assertEquals($expect, $result);
// Simple 'fixed position' DEPRECATED - not sure if it's ok that the array is not fillled up to the maximum.
$result = $this->sendMail->parseStringToArray('john@doe.com|jane@miller.com|Latest|Dear John');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John'];
$this->assertEquals($expect, $result);
// Simple 'token based'
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', '', '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// All (but attachment) 'token based'
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|r:reply@doe.com|A:on|g:123|x:234|c:july@doe.com,steve@doe.com|B:ceo@doe.com|h:Auto-Submit: fake|y:345|z:456|S:test.php');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', 'reply@doe.com', 'on', '123', '234', 'july@doe.com,steve@doe.com', 'ceo@doe.com', '', 'Auto-Submit: fake', '345', '456', 'test.php', '', ''];
$this->assertEquals($expect, $result);
// Single attachment 'token based'
$attach = [['F:fileadmin/test1.pdf']];
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// Three individual attachment 'token based'
// $attach = [ [ [ 'F' => 'fileadmin/test1.pdf' ], [ 'F' => 'fileadmin/test2.pdf' ], [ 'F' => 'fileadmin/test3.pdf' ] ] ] ;
$attach = [['F:fileadmin/test1.pdf'], ['F:fileadmin/test2.pdf'], ['F:fileadmin/test3.pdf']];
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// One individual attachment, one dual combined attachment
$attach = [['F:fileadmin/test1.pdf'], ['F:fileadmin/test2.pdf', 'F:fileadmin/test3.pdf']];
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|C|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// One individual attachment, one quad combined attachment
$attach = [['F:fileadmin/test1.pdf'], ['F:fileadmin/test2.pdf', 'F:fileadmin/test3.pdf', 'u:http://nzz.ch', 'U:export&a=100']];
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|C|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf|u:http://nzz.ch|U:export&a=100');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// Two quad combined attachments
$attach = [['d:output1.pdf', 'F:fileadmin/test11.pdf', 'F:fileadmin/test12.pdf', 'u:http://nzz.ch.1', 'U:export1&a=100'], ['d:output2.pdf', 'F:fileadmin/test21.pdf', 'F:fileadmin/test22.pdf', 'u:http://nzz.ch.2', 'U:export2&a=100']];
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|C|d:output1.pdf|F:fileadmin/test11.pdf|F:fileadmin/test12.pdf|u:http://nzz.ch.1|U:export1&a=100|C|d:output2.pdf|F:fileadmin/test21.pdf|F:fileadmin/test22.pdf|u:http://nzz.ch.2|U:export2&a=100');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment