Skip to content

Commit

Permalink
Merge pull request #48 from NetCommons3/issues/1468
Browse files Browse the repository at this point in the history
Issues/1468
  • Loading branch information
s-nakajima committed Aug 11, 2019
2 parents 1da2857 + 7a55624 commit 98ef490
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -6,8 +6,10 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2

sudo: false
dist: trusty

env:
- NETCOMMONS_VERSION=master DB=mysql
Expand Down
Expand Up @@ -77,7 +77,9 @@ public function testSetGroupList($strGroupId = null) {
$userIds = $this->_getExpectedUserIds([$strGroupId]);

//テスト実行
Current::initialize($this->controller);
$instance = Current::getInstance();
$instance->initialize($this->controller);

$this->controller->Groups->setGroupList(
$this->controller,
$this->__createGroupCondition($groupIds)
Expand Down Expand Up @@ -171,11 +173,9 @@ private function __validateViewValues($actualDataArray, $checkOption) {
} else {
$expectedData = $dbData[$checkKey];
}
if ($checkKey === $this->__modelGroup) {
unset($expectedData['created_user']);
unset($expectedData['created']);
unset($expectedData['modified_user']);
}

$expectedData = $this->_removeModified($expectedData);
$actualData[$checkKey] = $this->_removeModified($actualData[$checkKey]);

$this->assertEquals(
$expectedData,
Expand All @@ -184,4 +184,5 @@ private function __validateViewValues($actualDataArray, $checkOption) {
}
}
}

}
8 changes: 4 additions & 4 deletions Test/Case/Controller/GroupsController/UsersTest.php
Expand Up @@ -60,10 +60,10 @@ public function testUsersGet($paramGroupId, $existUserData) {
}
//テスト実行
$this->_testGetAction(
array('action' => 'users', '?' => $paramArray ),
array('action' => 'users', '?' => $paramArray),
array('method' => 'assertNotEmpty'),
null,
'json'
'view'
);
$this->__assertJson($existUserData);
if (!$existUserData) {
Expand Down Expand Up @@ -119,7 +119,7 @@ public function testUsersGetNoRoomId() {
array('action' => 'users', '?' => [ 'group_id' => '1,2'] ),
array('method' => 'assertNotEmpty'),
null,
'json'
'view'
);
$this->__assertJson(false);
}
Expand All @@ -138,7 +138,7 @@ public function testUsersGetDifferentRoomId() {
array('action' => 'users', '?' => [ 'group_id' => '1,2', 'room_id' => 999999998] ),
array('method' => 'assertNotEmpty'),
null,
'json'
'view'
);
$this->__assertJson(false);
}
Expand Down
3 changes: 2 additions & 1 deletion Test/Case/GroupsModelTestBase.php
Expand Up @@ -30,7 +30,8 @@ public function setUp() {
TestAuthGeneral::login($this);

CakeSession::write('Auth.User.UserRoleSetting.use_private_room', true);
Current::initialize($this->controller);
$instance = Current::getInstance();
$instance->initialize($this->controller);

//コントローラ内モデル
$this->_group = $this->controller->Group;
Expand Down
26 changes: 25 additions & 1 deletion Test/Case/GroupsTestBase.php
Expand Up @@ -87,7 +87,8 @@ public function setUp() {
parent::setUp();

CakeSession::write('Auth.User.UserRoleSetting.use_private_room', true);
Current::initialize($this->controller);
$instance = Current::getInstance();
$instance->initialize($this->controller);

//コントローラ内モデル
$this->_group = $this->controller->Group;
Expand Down Expand Up @@ -300,4 +301,27 @@ protected function _createViewClass($requestData = []) {
$View->loadHelpers();
return $View;
}

/**
* modifiedやcreatedカラムを除去する
*
* @param array $data データ
* @return array
*/
protected function _removeModified($data) {
if (isset($data['created_user'])) {
unset($data['created_user']);
}
if (isset($data['created'])) {
unset($data['created']);
}
if (isset($data['modified_user'])) {
unset($data['modified_user']);
}
if (isset($data['modified'])) {
unset($data['modified']);
}
return $data;
}

}
3 changes: 2 additions & 1 deletion Test/Case/GroupsViewTestBase.php
Expand Up @@ -29,7 +29,8 @@ public function setUp() {
TestAuthGeneral::login($this);

CakeSession::write('Auth.User.UserRoleSetting.use_private_room', true);
Current::initialize($this->controller);
$instance = Current::getInstance();
$instance->initialize($this->controller);

//コントローラ内モデル
$this->_group = $this->controller->Group;
Expand Down
2 changes: 2 additions & 0 deletions Test/Case/Model/GroupsUser/GetGroupUsersTest.php
Expand Up @@ -67,6 +67,8 @@ public function testGetGroupUsers($inputData = []) {
}
continue;
}

$actualUser['UploadFile'] = $this->_removeModified($actualUser['UploadFile']);
$this->assertEquals(
array_merge(
$expectedUser['UploadFile']['avatar'],
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Expand Up @@ -14,6 +14,5 @@
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-html" target="build/logs/clover"/>
</logging>
</phpunit>

0 comments on commit 98ef490

Please sign in to comment.