summaryrefslogtreecommitdiff
path: root/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php
blob: 36d1be1112b92b363ce8ed0ef914f1ccc745f8f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

require_once(dirname(__FILE__).'/BaseGateway.php');

/**
 * @package System.Data.TableGateway
 */
class TableGatewayDeleteByPkTest extends BaseGateway
{
	function test_delete_by_1_pk()
	{
		$this->add_record1();
		$id = $this->getGateway()->getLastInsertId();
		$deleted = $this->getGateway()->deleteByPk($id);

		$this->assertEquals(1, $deleted);
	}

	function test_delete_by_multiple_pk()
	{
		$this->add_record1();
		$id1 = $this->getGateway()->getLastInsertId();
		$this->add_record2();
		$id2 = $this->getGateway()->getLastInsertId();

		$deleted = $this->getGateway()->deleteByPk($id1, $id2);

		$this->assertEquals(2, $deleted);
	}

	function test_delete_by_multiple_pk2()
	{
		$this->add_record1();
		$id1 = $this->getGateway()->getLastInsertId();
		$this->add_record2();
		$id2 = $this->getGateway()->getLastInsertId();

		$deleted = $this->getGateway()->deleteByPk(array($id1, $id2));

		$this->assertEquals(2, $deleted);
	}

	function test_delete_by_multiple_pk3()
	{
		$this->add_record1();
		$id1 = $this->getGateway()->getLastInsertId();
		$this->add_record2();
		$id2 = $this->getGateway()->getLastInsertId();

		$deleted = $this->getGateway()->deleteByPk(array(array($id1), array($id2)));

		$this->assertEquals(2, $deleted);
	}
}