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
|
<?php
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\TestCase;
/**
* Test class to test rcube_contacts class
*/
class Framework_Contacts extends TestCase
{
/**
* Class constructor
*/
function test_class()
{
$object = new \rcube_contacts(null, null);
$this->assertInstanceOf(\rcube_contacts::class, $object, "Class constructor");
}
/**
* Test validate() method
*/
function test_validate()
{
$contacts = new \rcube_contacts(null, null);
$data = [];
$this->assertSame(false, $contacts->validate($data));
$this->assertSame(['type' => 3, 'message' => 'nonamewarning'], $contacts->get_error());
$data = ['name' => 'test'];
$this->assertSame(true, $contacts->validate($data));
$data = ['email' => '@example.org'];
$this->assertSame(false, $contacts->validate($data));
$this->assertSame(['type' => 3, 'message' => 'Invalid email address: @example.org'], $contacts->get_error());
$data = ['email' => 'test@test.com'];
$this->assertSame(true, $contacts->validate($data));
}
}
|