Files
roundcubemail/tests/Framework/Contacts.php
Michael Voříšek 6a53a1d853 Fix CS (whitespace, visibility) (#9297)
* Fix "method_argument_space"

* Fix "control_structure_continuation_position"

* Fix "new_with_parentheses"

* Fix "blank_line_before_statement"

* Fix "visibility_required"

* Fix some "array_indentation"

* Fix some "array_indentation" - unify all "rcube::raise_error" calls

* rm useless eslint ignores and add rules counts

* sort eslint ignores

* fix eslint ignores grammar

* Revert "Fix "blank_line_before_statement""

* fix CS 3.46.0
2024-01-04 14:26:35 +01:00

40 lines
1.0 KiB
PHP

<?php
/**
* Test class to test rcube_contacts class
*/
class Framework_Contacts extends PHPUnit\Framework\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));
}
}