| @@ 19-85 (lines=67) @@ | ||
| 16 | ||
| 17 | use Lakion\ApiTestCase\JsonApiTestCase; |
|
| 18 | ||
| 19 | class OrganizationMemberResolverTest extends JsonApiTestCase |
|
| 20 | { |
|
| 21 | public function testNonExistOrganizationResolver() |
|
| 22 | { |
|
| 23 | $this->organizationMemberResolver( |
|
| 24 | 'access-token-1', |
|
| 25 | 'non-exist-organization-id', |
|
| 26 | 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
| 27 | '/nonexistent_organization_by_organization_member_id' |
|
| 28 | ); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testUnauthorizedOrganizationResolver() |
|
| 32 | { |
|
| 33 | $this->organizationMemberResolver( |
|
| 34 | 'access-token-2', |
|
| 35 | '71298d2c-0ff4-11e7-93ae-92361f002671', |
|
| 36 | 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
| 37 | '/unauthorized_organization_by_organization_member_id' |
|
| 38 | ); |
|
| 39 | } |
|
| 40 | ||
| 41 | public function testNonExistOrganizationMemberResolver() |
|
| 42 | { |
|
| 43 | $this->organizationMemberResolver( |
|
| 44 | 'access-token-1', |
|
| 45 | '71298d2c-0ff4-11e7-93ae-92361f002671', |
|
| 46 | 'non-exist-organization-member-id', |
|
| 47 | '/nonexistent_organization_member_by_id' |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function testOrganizationMemberResolver() |
|
| 52 | { |
|
| 53 | $this->organizationMemberResolver( |
|
| 54 | 'access-token-1', |
|
| 55 | '71298d2c-0ff4-11e7-93ae-92361f002671', |
|
| 56 | 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
| 57 | '/organization_member' |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | ||
| 61 | private function organizationMemberResolver($token, $organizationId, $value, $jsonResult) |
|
| 62 | { |
|
| 63 | $this->client->request('POST', '/?access_token=' . $token, [ |
|
| 64 | 'query' => <<<EOF |
|
| 65 | query MemberQueryRequest(\$organizationId: ID!, \$organizationMemberId: ID!) { |
|
| 66 | organizationMember(organizationId: \$organizationId, organizationMemberId: \$organizationMemberId) { |
|
| 67 | id, |
|
| 68 | organization { |
|
| 69 | id, |
|
| 70 | name |
|
| 71 | } |
|
| 72 | } |
|
| 73 | } |
|
| 74 | EOF |
|
| 75 | , 'variables' => [ |
|
| 76 | 'organizationId' => $organizationId, |
|
| 77 | 'organizationMemberId' => $value, |
|
| 78 | ], |
|
| 79 | ]); |
|
| 80 | ||
| 81 | $response = $this->client->getResponse(); |
|
| 82 | ||
| 83 | $this->assertResponse($response, 'graphql/query/organization' . $jsonResult); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| @@ 19-85 (lines=67) @@ | ||
| 16 | ||
| 17 | use Lakion\ApiTestCase\JsonApiTestCase; |
|
| 18 | ||
| 19 | class OwnerResolverTest extends JsonApiTestCase |
|
| 20 | { |
|
| 21 | public function testNonExistOrganizationResolver() |
|
| 22 | { |
|
| 23 | $this->ownerResolver( |
|
| 24 | 'access-token-1', |
|
| 25 | 'non-exist-organization-id', |
|
| 26 | 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
| 27 | '/nonexistent_organization_by_owner_id' |
|
| 28 | ); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testUnauthorizedOrganizationResolver() |
|
| 32 | { |
|
| 33 | $this->ownerResolver( |
|
| 34 | 'access-token-2', |
|
| 35 | '71298d2c-0ff4-11e7-93ae-92361f002671', |
|
| 36 | 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
| 37 | '/unauthorized_organization_by_owner_id' |
|
| 38 | ); |
|
| 39 | } |
|
| 40 | ||
| 41 | public function testNonExistOwnerResolver() |
|
| 42 | { |
|
| 43 | $this->ownerResolver( |
|
| 44 | 'access-token-1', |
|
| 45 | '71298d2c-0ff4-11e7-93ae-92361f002671', |
|
| 46 | 'non-exist-owner-id', |
|
| 47 | '/nonexistent_owner_by_id' |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function testOwnerResolver() |
|
| 52 | { |
|
| 53 | $this->ownerResolver( |
|
| 54 | 'access-token-1', |
|
| 55 | '71298d2c-0ff4-11e7-93ae-92361f002671', |
|
| 56 | 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
| 57 | '/owner' |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | ||
| 61 | private function ownerResolver($token, $organizationId, $value, $jsonResult) |
|
| 62 | { |
|
| 63 | $this->client->request('POST', '/?access_token=' . $token, [ |
|
| 64 | 'query' => <<<EOF |
|
| 65 | query MemberQueryRequest(\$organizationId: ID!, \$ownerId: ID!) { |
|
| 66 | owner(organizationId: \$organizationId, ownerId: \$ownerId) { |
|
| 67 | id, |
|
| 68 | organization { |
|
| 69 | id, |
|
| 70 | name |
|
| 71 | } |
|
| 72 | } |
|
| 73 | } |
|
| 74 | EOF |
|
| 75 | , 'variables' => [ |
|
| 76 | 'organizationId' => $organizationId, |
|
| 77 | 'ownerId' => $value, |
|
| 78 | ], |
|
| 79 | ]); |
|
| 80 | ||
| 81 | $response = $this->client->getResponse(); |
|
| 82 | ||
| 83 | $this->assertResponse($response, 'graphql/query/organization' . $jsonResult); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||