FormatterTest::testAddOrRemoveS()   A
last analyzed

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.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package A simple ORM that performs basic CRUD operations
5
 * @author Surajudeen AKANDE <[email protected]>
6
 * @license MIT <https://opensource.org/licenses/MIT>
7
 * @link http://www.github.com/andela-sakande
8
 * */
9
namespace Sirolad\Test;
10
11
use Sirolad\Libraries\Formatter;
12
13
/**
14
 * Test for Formatter class
15
 **/
16
class FormatterTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * Test for singularize or pluralize
20
     * */
21
    public function testAddOrRemoveS()
22
    {
23
        $this->assertEquals('user', Formatter::addOrRemoveS('users'));
24
        $this->assertEquals('cars', Formatter::addOrRemoveS('car'));
25
        $this->assertNotEquals('cars', Formatter::addOrRemoveS('cars'));
26
    }
27
28
    /**
29
     * Test for SQL query placeholders
30
     **/
31
    public function testGenerateUnnamedPlaceholders()
32
    {
33
        $this->assertEquals(['?', '?', '?', '?'], Formatter::generateUnnamedPlaceholders(['username', 'password', 'email', 'date_created']));
34
        $this->assertNotEquals(['?', '?', '?', '?'], Formatter::generateUnnamedPlaceholders(['username', 'password', 'email']));
35
    }
36
37
    /**
38
     * Test to tokenize values of SQL query
39
     * */
40
    public function testTokenize()
41
    {
42
        $this->assertEquals('username,password,email', Formatter::tokenize('username,password,email', ','));
43
    }
44
45
    /**
46
     * Test that SQL query is used associatively
47
     * */
48
    public function testMakeAssociativeArray()
49
    {
50
        $this->assertEquals(["token=NULL", 'token_expire="today"'], Formatter::makeAssociativeArray(['' => '', 'token' => null, 'token_expire' => 'today']));
51
    }
52
}
53