File: Contacts.php

package info (click to toggle)
roundcube 1.6.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,868 kB
  • sloc: javascript: 195,588; php: 76,818; sql: 3,150; sh: 2,882; pascal: 1,079; makefile: 234; xml: 93; perl: 73; ansic: 48; python: 21
file content (43 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download
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));
    }
}