Chris@18: drupalCreateContentType([ Chris@18: 'type' => 'article', Chris@18: 'name' => 'Article', Chris@18: ]); Chris@18: $node = $this->createNode(['type' => 'article']); Chris@18: $editor_user = $this->drupalCreateUser([ Chris@18: 'access content', Chris@18: 'create article content', Chris@18: 'edit any article content', Chris@18: 'access in-place editing', Chris@18: ]); Chris@18: $this->drupalLogin($editor_user); Chris@18: Chris@18: $custom_render_url = $this->buildUrl('quickedit/form/node/' . $node->id() . '/body/en/quickedit_test-custom-render-data'); Chris@18: Chris@18: $client = $this->getHttpClient(); Chris@18: $post = ['nocssjs' => 'true']; Chris@18: $response = $client->post($custom_render_url, [ Chris@18: 'body' => http_build_query($post), Chris@18: 'query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax'], Chris@18: 'cookies' => $this->getSessionCookies(), Chris@18: 'headers' => [ Chris@18: 'Accept' => 'application/json', Chris@18: 'Content-Type' => 'application/x-www-form-urlencoded', Chris@18: ], Chris@18: 'http_errors' => FALSE, Chris@18: ]); Chris@18: Chris@18: $this->assertEquals(200, $response->getStatusCode()); Chris@18: Chris@18: $ajax_commands = Json::decode($response->getBody()); Chris@18: // Request editing to render results with the custom render pipeline. Chris@18: Chris@18: // Prepare form values for submission. drupalPostAJAX() is not suitable for Chris@18: // handling pages with JSON responses, so we need our own solution here. Chris@18: $form_tokens_found = preg_match('/\sname="form_token" value="([^"]+)"/', $ajax_commands[0]['data'], $token_match) && preg_match('/\sname="form_build_id" value="([^"]+)"/', $ajax_commands[0]['data'], $build_id_match); Chris@18: $this->assertTrue($form_tokens_found, 'Form tokens found in output.'); Chris@18: Chris@18: $post = [ Chris@18: 'form_id' => 'quickedit_field_form', Chris@18: 'form_token' => $token_match[1], Chris@18: 'form_build_id' => $build_id_match[1], Chris@18: 'body[0][summary]' => '', Chris@18: 'body[0][value]' => '
Fine thanks.
', Chris@18: 'body[0][format]' => 'filtered_html', Chris@18: 'op' => t('Save'), Chris@18: ]; Chris@18: // Assume there is another field on this page, which doesn't use a custom Chris@18: // render pipeline, but the default one, and it uses the "full" view mode. Chris@18: $post += ['other_view_modes[]' => 'full']; Chris@18: Chris@18: // Submit field form and check response. Should render with the custom Chris@18: // render pipeline. Chris@18: $response = $client->post($custom_render_url, [ Chris@18: 'body' => http_build_query($post), Chris@18: 'query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax'], Chris@18: 'cookies' => $this->getSessionCookies(), Chris@18: 'headers' => [ Chris@18: 'Accept' => 'application/json', Chris@18: 'Content-Type' => 'application/x-www-form-urlencoded', Chris@18: ], Chris@18: 'http_errors' => FALSE, Chris@18: ]); Chris@18: $ajax_commands = Json::decode($response->getBody()); Chris@18: $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); Chris@18: $this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldFormSaved command.'); Chris@18: $this->assertTrue(strpos($ajax_commands[0]['data'], 'Fine thanks.'), 'Form value saved and printed back.'); Chris@18: $this->assertTrue(strpos($ajax_commands[0]['data'], '