Completed
Push — master ( 0022f4...ad9fa0 )
by Michal
04:27
created

NotificationsControllerTest::testMassAction()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 29
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace App\Test\TestCase\Controller;
4
5
use Cake\ORM\TableRegistry;
6
use Cake\TestSuite\IntegrationTestCase;
7
8
/**
9
 * NotificationsController Test Case.
10
 */
11
class NotificationsControllerTest extends IntegrationTestCase
12
{
13
    /**
14
     * Fixtures.
15
     *
16
     * @var array
17
     */
18
    public $fixtures = array(
19
        'app.notifications',
20
        'app.developers',
21
        'app.reports',
22
        'app.incidents',
23
    );
24
25
    public function setUp()
26
    {
27
        $this->Notifications = TableRegistry::get('Notifications');
0 ignored issues
show
Bug introduced by
The property Notifications 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...
28
        $this->session(array('Developer.id' => 1));
29
    }
30
31
    public function testMassAction()
32
    {
33
        /* Test case 1 */
34
        $this->post('/notifications/mass_action',
35
            array('notifs' => array('1', '3'))
36
        );
37
38
        $notifications = $this->Notifications->find('all', array('fields' => array('Notifications.id')));
39
        $this->assertInstanceOf('Cake\ORM\Query', $notifications);
40
        $actual = $notifications->hydrate(false)->toArray();
41
        $expected = array(
42
            array(
43
                'id' => '2',
44
            ),
45
        );
46
        $this->assertEquals($actual, $expected);
47
48
49
        /* Test case 2 */
50
        $this->post('/notifications/mass_action',
51
            array('mark_all' => 1)
52
        );
53
54
        $notifications = $this->Notifications->find('all', array('fields' => array('Notifications.id')));
55
        $this->assertInstanceOf('Cake\ORM\Query', $notifications);
56
        $actual = $notifications->hydrate(false)->toArray();
57
        $expected = array();
58
        $this->assertEquals($actual, $expected);
59
    }
60
}
61