tests/test-tag-and-attribute-sanitizer.php
diff --git a/tests/test-amp-crowdsignal-embed-handler.php b/tests/test-amp-crowdsignal-embed-handler.php
new file mode 100644
index 00000000000..b8516e3dc52
--- /dev/null
+++ b/tests/test-amp-crowdsignal-embed-handler.php
@@ -0,0 +1,108 @@
+ 'rich',
+ 'version' => '1.0',
+ 'provider_name' => 'Crowdsignal',
+ 'provider_url' => 'https://crowdsignal.com',
+ 'title' => 'Which design do you prefer?',
+ 'html' => '', // phpcs:ignore
+ );
+ $survey_response = array(
+ 'type' => 'rich',
+ 'version' => '1.0',
+ 'provider_name' => 'Crowdsignal',
+ 'provider_url' => 'https://crowdsignal.com',
+ 'html' => '',
+ );
+
+ $data = array(
+ 'poll.fm' => array(
+ 'https://poll.fm/7012505',
+ 'Which design do you prefer?
',
+ $poll_response,
+ ),
+
+ 'polldaddy_poll' => array(
+ 'https://polldaddy.com/poll/7012505/',
+ 'Which design do you prefer?
',
+ $poll_response,
+ ),
+
+ 'polldaddy_survey' => array(
+ 'https://rydk.polldaddy.com/s/test-survey',
+ 'View Survey
',
+ $survey_response,
+ ),
+ );
+
+ /*
+ * There is a bug with WordPress's oEmbed handling for Crowdsignal surveys.
+ * See .
+ */
+ if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '>=' ) ) {
+ $data['survey.fm'] = array(
+ 'https://rydk.survey.fm/test-survey',
+ 'View Survey
',
+ $survey_response,
+ );
+ }
+
+ return $data;
+ }
+
+ /**
+ * Test conversion.
+ *
+ * @dataProvider get_conversion_data
+ *
+ * @param string $url Source.
+ * @param string $expected Expected.
+ * @param string $oembed_response oEmbed response.
+ */
+ public function test_conversion( $url, $expected, $oembed_response ) {
+ add_filter(
+ 'pre_http_request',
+ function ( $pre, $r, $request_url ) use ( $url, $oembed_response ) {
+ unset( $r );
+ if ( false === strpos( $request_url, 'crowdsignal' ) ) {
+ return $pre;
+ }
+
+ return array(
+ 'body' => wp_json_encode( $oembed_response ),
+ 'response' => array(
+ 'code' => 200,
+ 'message' => 'OK',
+ ),
+ );
+ },
+ 10,
+ 3
+ );
+
+ $embed = new AMP_Crowdsignal_Embed_Handler();
+ $embed->register_embed();
+ $filtered_content = apply_filters( 'the_content', $url );
+
+ $this->assertEquals( trim( $expected ), trim( $filtered_content ) );
+ }
+}
diff --git a/wpcom/class-amp-polldaddy-embed.php b/wpcom/class-amp-polldaddy-embed.php
deleted file mode 100644
index f0696641363..00000000000
--- a/wpcom/class-amp-polldaddy-embed.php
+++ /dev/null
@@ -1,105 +0,0 @@
-render_link( $url, $attr['title'] );
- } else {
- $output = $wp_embed->shortcode( $attr, $url );
- }
-
- return $output;
- }
-
- /**
- * Filter oEmbed HTML for PollDaddy to for AMP output.
- *
- * @param string $cache Cache for oEmbed.
- * @param string $url Embed URL.
- * @param array $attr Shortcode attributes.
- * @return string Embed.
- */
- public function filter_embed_oembed_html( $cache, $url, $attr ) {
- $parsed_url = wp_parse_url( $url );
- if ( false === strpos( $parsed_url['host'], 'polldaddy.com' ) ) {
- return $cache;
- }
-
- $output = '';
-
- // Poll oEmbed responses include noscript.
- if ( preg_match( '##', $cache, $matches ) ) {
- $output = $matches[1];
- }
-
- if ( empty( $output ) ) {
- if ( ! empty( $attr['title'] ) ) {
- $name = $attr['title'];
- } elseif ( false !== strpos( $url, 'polldaddy.com/s' ) ) {
- $name = __( 'View Survey', 'amp' );
- } else {
- $name = __( 'View Poll', 'amp' );
- }
- $output = $this->render_link( $url, $name );
- }
-
- return $output;
- }
-
- /**
- * Render poll/survey link.
- *
- * @param string $url Link URL.
- * @param string $title Link Text.
- * @return string Link.
- */
- private function render_link( $url, $title ) {
- return sprintf( '' . esc_html( $title ) . '
' );
- }
-}