summaryrefslogtreecommitdiff
path: root/tests/simple_unit/TableGateway/DeleteByPkTest.php
blob: 49b2d86cc3cbf69673413db7f001872de856b39b (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
<?php

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

class DeleteByPkTest extends BaseGatewayTest
{
	function test_delete_by_1_pk()
	{
		$this->add_record1();
		$id = $this->getGateway()->getLastInsertId();
		$deleted = $this->getGateway()->deleteByPk($id);

		$this->assertEqual(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->assertEqual(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->assertEqual(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->assertEqual(2, $deleted);
	}
}