Пример #1
0
 public function testtoActivityAdminHistoryApiArray()
 {
     $adminHistoryModel = new \Model_ActivityAdminHistory();
     $adminHistoryModel->loadBean(new \RedBeanPHP\OODBBean());
     $adminHistoryModel->admin_id = 2;
     $expected = array('id' => '', 'ip' => '', 'created_at' => '', 'staff' => array('id' => $adminHistoryModel->admin_id, 'name' => '', 'email' => ''));
     $adminModel = new \Model_Admin();
     $adminModel->loadBean(new \RedBeanPHP\OODBBean());
     $adminModel->id = 2;
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('load')->will($this->returnValue($adminModel));
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $service = new \Box\Mod\Staff\Service();
     $service->setDi($di);
     $result = $service->toActivityAdminHistoryApiArray($adminHistoryModel);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertTrue(count(array_diff(array_keys($expected), array_keys($result))) == 0, 'Missing array key values.');
 }