Completed
Push — master ( 92e541...c9fde5 )
by Blake
05:50
created

ProgressHelperTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * Phone Helper (https://github.com/PotatoPowered/phone-helper)
4
 *
5
 * Licensed under The MIT License
6
 * For full copyrgiht and license information, please see the LICENSE
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @author      Blake Sutton <[email protected]>
10
 * @copyright   Copyright (c) Potato Powered Software
11
 * @link        http://potatopowered.net
12
 * @since       1.0
13
 * @version     1.0
14
 * @license     http://www.opensource.org/licenses/mit-license.php MIT License
15
 */
16
namespace PhoneHelper\Test\TestCase\View\Helper;
17
18
use Cake\TestSuite\TestCase;
19
use Cake\View\View;
20
use PhoneHelper\View\Helper\PhoneHelper;
21
22
/**
23
 * PhoneHelper Test Class
24
 *
25
 * This class contains the main tests for the PhoneHelper Class.
26
 */
27
class ProgressHelperTest extends TestCase
28
{
29
    /**
30
     * Setup the application so that we can run the tests.
31
     *
32
     * The setup involves initializing a new CakePHP view and using that to
33
     * get a copy of the PhoneHelper.
34
     */
35
    public function setUp()
36
    {
37
        parent::setUp();
38
        $View = new View();
39
        $this->Phone = new PhoneHelper($View);
1 ignored issue
show
Bug introduced by
The property Phone does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
40
    }
41
42
    /**
43
     * Run the plugin tests
44
     *
45
     * This function runs a few tests to check if 7 and 10 digit phone number
46
     * prettifying is working correctly.
47
     */
48
    public function testPhone()
49
    {
50
        $tenDigit = $this->Phone->phone('1234567890');
51
        $sevenDigit = $this->Phone->phone('1234567');
52
        $original = $this->Phone->phone('12345678901');
53
        $this->assertEquals('(123) 456-7890', $tenDigit);
54
        $this->assertEquals('123-4567', $sevenDigit);
55
        $this->assertEquals('12345678901', $original);
56
    }
57
}
58