Test Setup Failed
Pull Request — master (#215)
by Viruthagiri
12:15
created

AddCustomFields   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 74
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testAddCustomFields() 0 61 1
A tearDown() 0 4 1
1
<?php
2
class AddCustomFields extends WP_UnitTestCase
3
{
4
    public function setUp()
5
    {
6
        parent::setUp();
7
    }
8
9
    public function testAddCustomFields()
10
    {
11
        $field = array(
12
            'listing_type'  => 'gd_place',
13
            'data_type'     => '',
14
            'field_type'    => 'select',
15
            'admin_title'   => __( 'Place Type', 'test' ),
16
            'admin_desc'    => __( 'Select the place type.', 'test' ),
17
            'site_title'    => __( 'Place Type', 'test' ),
18
            'htmlvar_name'  => 'test_place_type',
19
            'default_value' => '',
20
            'option_values' => 'Hotel,Bar,Restaurant,Pub',
21
            'is_default'    => '1',
22
            'is_admin'      => '1',
23
            'clabels'       => __( 'Place Type', 'test' )
24
        );
25
26
        $lastid = geodir_custom_field_save( $field );
27
28
        $this->assertTrue(is_int($lastid));
29
30
31
        $field2 = array(
32
            'listing_type'  => 'gd_place',
33
            'data_type'     => 'VARCHAR',
34
            'field_type'    => 'url',
35
            'admin_title'   => __( 'Website Link', 'test' ),
36
            'admin_desc'    => __( 'Enter the website link.', 'test' ),
37
            'site_title'    => __( 'Website Link', 'test' ),
38
            'htmlvar_name'  => 'test_ws_link',
39
            'default_value' => '',
40
            'option_values' => '',
41
            'is_default'    => '1',
42
            'is_admin'      => '1',
43
            'clabels'       => __( 'Website Link', 'test' )
44
        );
45
46
        $lastid2 = geodir_custom_field_save( $field2 );
47
48
        $this->assertTrue(is_int($lastid2));
49
50
        //test error
51
        $field3 = array(
52
            'listing_type'  => 'gd_place',
53
            'data_type'     => '',
54
            'field_type'    => 'select',
55
            'admin_title'   => __( 'Place Type', 'test' ),
56
            'admin_desc'    => __( 'Select the place type.', 'test' ),
57
            'site_title'    => __( 'Place Type', 'test' ),
58
            'htmlvar_name'  => 'test_place_type',
59
            'default_value' => '',
60
            'option_values' => 'Hotel,Bar,Restaurant,Pub',
61
            'is_default'    => '1',
62
            'is_admin'      => '1',
63
            'clabels'       => __( 'Place Type', 'test' )
64
        );
65
66
        $error = geodir_custom_field_save( $field3 );
67
68
        $this->assertContains( 'HTML Variable Name should be a unique name', $error );
69
    }
70
71
    public function tearDown()
72
    {
73
        parent::tearDown();
74
    }
75
}
76
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...