filter = new TaskFilter(); $request->filter->performers = [27]; $request->filter->status = TaskStatus::COMPLETED; $mock = static::createApiMockBuilder('tasks'); $mock->matchMethod(RequestMethod::GET) ->matchQuery(self::encodeFormArray($request)) ->reply(200) ->withBody($json); $client = TestClientFactory::createClient($mock->getClient()); $response = $client->tasks->list($request); self::assertModelEqualsToResponse($json, $response); } public function testCreate(): void { $json = <<<'EOF' { "success": true, "id": 1 } EOF; $request = new TasksCreateRequest(); $request->task = new Task(); $request->task->text = 'Test task #1'; $request->task->performerId = 27; $request->task->customer = new AbstractCustomer(null, 'ru1067815391', 'aliexpress'); $request->site = 'aliexpress'; $mock = static::createApiMockBuilder('tasks/create'); $mock->matchMethod(RequestMethod::POST) ->matchBody(self::encodeForm($request)) ->reply(200) ->withBody($json); $client = TestClientFactory::createClient($mock->getClient()); $response = $client->tasks->create($request); self::assertModelEqualsToResponse($json, $response); } public function testGet(): void { $json = <<<'EOF' { "success": true, "task": { "id": 1, "text": "Test task #1", "createdAt": "2021-03-05 12:35:29", "complete": false, "performer": 27, "performerType": "user", "customer": { "type": "customer", "id": 4976, "externalId": "ru1067815391", "site": "aliexpress" } } } EOF; $mock = static::createApiMockBuilder('tasks/1'); $mock->matchMethod(RequestMethod::GET) ->reply(200) ->withBody($json); $client = TestClientFactory::createClient($mock->getClient()); $response = $client->tasks->get(1); self::assertModelEqualsToResponse($json, $response); } public function testEdit(): void { $json = <<<'EOF' { "success": true } EOF; $request = new TasksCreateRequest(); $request->task = new Task(); $request->task->text = 'Test task #1 (edited)'; $request->site = 'aliexpress'; $mock = static::createApiMockBuilder('tasks/1/edit'); $mock->matchMethod(RequestMethod::POST) ->matchBody(self::encodeForm($request)) ->reply(200) ->withBody($json); $client = TestClientFactory::createClient($mock->getClient()); $response = $client->tasks->edit(1, $request); self::assertModelEqualsToResponse($json, $response); } }