mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-04 15:24:02 +01:00
* fix Tests\Browser\TestCase imports * fix remaining imports * fix PHPUnit\Framework\TestCase imports * import GuzzleHttp\Client * fix remaining * "php_unit_method_casing" is not todo * fix "single_line_comment_spacing" * fix 2nd commit done using older fixer
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Test class to test rcube_contacts class
|
|
*/
|
|
class Framework_Contacts extends TestCase
|
|
{
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
public function test_class()
|
|
{
|
|
$object = new rcube_contacts(null, null);
|
|
|
|
$this->assertInstanceOf('rcube_contacts', $object, 'Class constructor');
|
|
}
|
|
|
|
/**
|
|
* Test validate() method
|
|
*/
|
|
public function test_validate()
|
|
{
|
|
$contacts = new rcube_contacts(null, null);
|
|
|
|
$data = [];
|
|
$this->assertFalse($contacts->validate($data));
|
|
$this->assertSame(['type' => 3, 'message' => 'nonamewarning'], $contacts->get_error());
|
|
|
|
$data = ['name' => 'test'];
|
|
$this->assertTrue($contacts->validate($data));
|
|
|
|
$data = ['email' => '@example.org'];
|
|
$this->assertFalse($contacts->validate($data));
|
|
$this->assertSame(['type' => 3, 'message' => 'Invalid email address: @example.org'], $contacts->get_error());
|
|
|
|
$data = ['email' => 'test@test.com'];
|
|
$this->assertTrue($contacts->validate($data));
|
|
}
|
|
}
|