Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mail.php « lib « tests - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 813dde1944f5c9c8e466dedd5e5d712a5dfbcd94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
 * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

class Test_Mail extends \Test\TestCase {

	/**
	 * @dataProvider buildAsciiEmailProvider
	 * @param $expected
	 * @param $address
	 */
	public function testBuildAsciiEmail($expected, $address) {
		if (!function_exists('idn_to_ascii')) {
			$this->markTestSkipped(
				'The intl extension is not available.'
			);
		}

		$actual = \OC_Mail::buildAsciiEmail($address);
		$this->assertEquals($expected, $actual);
	}

	public function buildAsciiEmailProvider() {
		return array(
			array('info@example.com', 'info@example.com'),
			array('info@xn--cjr6vy5ejyai80u.com', 'info@國際化域名.com'),
			array('info@xn--mller-kva.de', 'info@müller.de'),
			array('info@xn--mller-kva.xn--mller-kva.de', 'info@müller.müller.de'),
		);
	}

	public function validateMailProvider() {
		return array(
			array('infoatexample.com', false),
			array('info', false),
		);
	}

	/**
	 * @dataProvider validateMailProvider
	 * @param $address
	 * @param $expected
	 */
	public function testValidateEmail($address, $expected) {
		$actual = \OC_Mail::validateAddress($address);
		$this->assertEquals($expected, $actual);
	}

}