Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Roundcube\Tests\Framework; use PHPUnit\Framework\TestCase; /** * Test ..

Decoded Output download

<?php

namespace Roundcube\Tests\Framework;

use PHPUnit\Framework\TestCase;

/**
 * Test class to test rcube_addressbook class
 */
class AddressbookTest extends TestCase
{
    /**
     * Test for get_col_values() method
     */
    public function test_get_col_values()
    {
        $data = ['email' => '[email protected]', 'other' => 'test'];
        $result = 
cube_addressbook::get_col_values('email', $data, true);

        $this->assertSame(['[email protected]'], $result);

        $data = ['email:home' => '[email protected]', 'other' => 'test'];
        $result = 
cube_addressbook::get_col_values('email', $data, true);

        $this->assertSame(['[email protected]'], $result);

        $data = ['email:home' => '[email protected]', 'other' => 'test'];
        $result = 
cube_addressbook::get_col_values('email', $data, false);

        $this->assertSame(['home' => ['[email protected]']], $result);
    }

    /**
     * Test for compose_list_name() method
     */
    public function test_compose_list_name()
    {
        $contact = [];
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('', $result);

        $contact = ['email' => '[email protected]'];
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('[email protected]', $result);

        $contact = ['email' => '[email protected]', 'organization' => 'Org'];
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('Org', $result);

        $contact['firstname'] = 'First';
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('First', $result);

        $contact['surname'] = 'Last';
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('First Last', $result);

        $contact['name'] = 'Name';
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('Name', $result);

        unset($contact['name']);
        $contact['prefix'] = 'Dr.';
        $contact['suffix'] = 'Jr.';
        $contact['middlename'] = 'M.';
        $result = 
cube_addressbook::compose_list_name($contact);

        $this->assertSame('Dr. First M. Last Jr.', $result);

        // TODO: Test different modes
        /*
        rcube::get_instance()->config->set('addressbook_name_listing', 3);
        $result = rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Last, First M.', $result);

        rcube::get_instance()->config->set('addressbook_name_listing', 2);
        $result = rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Last First M.', $result);

        rcube::get_instance()->config->set('addressbook_name_listing', 1);
        $result = rcube_addressbook::compose_list_name($contact);

        $this->assertSame('First M. Last', $result);
        */
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Roundcube\Tests\Framework;

use PHPUnit\Framework\TestCase;

/**
 * Test class to test rcube_addressbook class
 */
class AddressbookTest extends TestCase
{
    /**
     * Test for get_col_values() method
     */
    public function test_get_col_values()
    {
        $data = ['email' => '[email protected]', 'other' => 'test'];
        $result = \rcube_addressbook::get_col_values('email', $data, true);

        $this->assertSame(['[email protected]'], $result);

        $data = ['email:home' => '[email protected]', 'other' => 'test'];
        $result = \rcube_addressbook::get_col_values('email', $data, true);

        $this->assertSame(['[email protected]'], $result);

        $data = ['email:home' => '[email protected]', 'other' => 'test'];
        $result = \rcube_addressbook::get_col_values('email', $data, false);

        $this->assertSame(['home' => ['[email protected]']], $result);
    }

    /**
     * Test for compose_list_name() method
     */
    public function test_compose_list_name()
    {
        $contact = [];
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('', $result);

        $contact = ['email' => '[email protected]'];
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('[email protected]', $result);

        $contact = ['email' => '[email protected]', 'organization' => 'Org'];
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Org', $result);

        $contact['firstname'] = 'First';
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('First', $result);

        $contact['surname'] = 'Last';
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('First Last', $result);

        $contact['name'] = 'Name';
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Name', $result);

        unset($contact['name']);
        $contact['prefix'] = 'Dr.';
        $contact['suffix'] = 'Jr.';
        $contact['middlename'] = 'M.';
        $result = \rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Dr. First M. Last Jr.', $result);

        // TODO: Test different modes
        /*
        rcube::get_instance()->config->set('addressbook_name_listing', 3);
        $result = rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Last, First M.', $result);

        rcube::get_instance()->config->set('addressbook_name_listing', 2);
        $result = rcube_addressbook::compose_list_name($contact);

        $this->assertSame('Last First M.', $result);

        rcube::get_instance()->config->set('addressbook_name_listing', 1);
        $result = rcube_addressbook::compose_list_name($contact);

        $this->assertSame('First M. Last', $result);
        */
    }
}

Function Calls

None

Variables

None

Stats

MD5 3b80952eaca733b05d5f4c8e1eb3014c
Eval Count 0
Decode Time 73 ms