1: <?php
2: namespace tests\integration\barebones\models\system;
3:
4: use tests\integration\barebones\BarebonesTestCase;
5: use ClientModel;
6: use Session;
7: use barebones\models\inventory\InventoryClassModel;
8:
9: class ClientModelTest extends BarebonesTestCase
10: {
11: public function testNewClientModel()
12: {
13: $model = new ClientModel();
14: $model->cli_cus_id=8;
15: $model->save();
16: $invc = InventoryClassModel::findFirstMatch(array(
17: "invc_type" => "1",
18: "invc_cli_id" => $model->cli_id
19: ), array(
20: 'db' => '_'.$model->cli_cus_id
21: ));
22: $this->assertNotNull($invc);
23: Session::set('usr_cur_customer_id', 8);
24: $invc = new InventoryClassModel();
25: $this->assertEquals(Session::get('usr_cur_customer_id'), 8);
26: $this->assertEquals($invc->invc_cus_id, 8);
27: }
28:
29: public function testWhatChanged()
30: {
31:
32: $model = new ClientModel();
33: $this->assertEquals(count($model->whatChanged()), 0);
34:
35: $model->cli_cus_id = 8;
36: $model->cli_name = "what up";
37:
38: $this->assertEquals(count($model->whatChanged()), 2);
39:
40: $model->set(array(
41: "cli_cus_id" => 8,
42: "cli_phone" => "test",
43: "unknown" => 1
44: ));
45:
46: $this->assertEquals(count($model->whatChanged()), 4);
47:
48:
49: $model = ClientModel::fetch(134641);
50: $this->assertEquals(count($model->whatChanged()), 0);
51:
52: $model->cli_name = "what up";
53: $this->assertEquals(count($model->whatChanged()), 1);
54: }
55: }
56: