| 46 | | } |
| 47 | | No newline at end of file |
| | 46 | |
| | 47 | /** |
| | 48 | * Test Kindle Instant Previews embeds. |
| | 49 | * |
| | 50 | * @ticket 38181 |
| | 51 | */ |
| | 52 | function test_amazon_kindle_non_book_embed() { |
| | 53 | $out = wp_oembed_get( 'http://www.amazon.com/All-New-Kindle-E-reader-Glare-Free-Touchscreen/dp/B00ZV9PXP2/r' ); |
| | 54 | $this->assertFalse( $out ); |
| | 55 | |
| | 56 | $out = wp_oembed_get( 'https://www.amazon.com/All-New-Kindle-E-reader-Glare-Free-Touchscreen/dp/B00ZV9PXP2/r' ); |
| | 57 | $this->assertFalse( $out ); |
| | 58 | } |
| | 59 | |
| | 60 | /** |
| | 61 | * Support for Kindle previews shared from Kindle devices or apps. |
| | 62 | * |
| | 63 | * @link http://www.amazon.com/bettersharing Kindle Instant Previews sharing homepage |
| | 64 | * |
| | 65 | * @ticket 38181 |
| | 66 | */ |
| | 67 | function test_amazon_kindle_shared_preview_embed() { |
| | 68 | // Book. |
| | 69 | $out = wp_oembed_get( 'https://read.amazon.com/kp/kshare?asin=B008TW1HMG&tag=foo-20' ); |
| | 70 | $this->assertContains( 'https://read.amazon.com/kp/card?', $out ); |
| | 71 | $this->assertContains( 'asin=B008TW1HMG', $out ); |
| | 72 | $this->assertContains( 'tag=foo-20', $out ); |
| | 73 | |
| | 74 | // Quote. |
| | 75 | $out = wp_oembed_get( 'https://read.amazon.com/kp/kshare?asin=B00DPM7TIG&tag=foo-20&id=XD3ezAVVQ3KP0bWxSFvosg' ); |
| | 76 | $this->assertContains( 'https://read.amazon.com/kp/card?', $out ); |
| | 77 | $this->assertContains( 'asin=B00DPM7TIG', $out ); |
| | 78 | $this->assertContains( 'tag=foo-20', $out ); |
| | 79 | |
| | 80 | // Reading progress. |
| | 81 | $out = wp_oembed_get( 'https://read.amazon.com/kp/kshare?asin=B007P7HRS4&id=Sd6UmMYYTc6rHl1BYkXU2g&tag=foo-20' ); |
| | 82 | $this->assertContains( 'https://read.amazon.com/kp/card?', $out ); |
| | 83 | $this->assertContains( 'asin=B007P7HRS4', $out ); |
| | 84 | $this->assertContains( 'tag=foo-20', $out ); |
| | 85 | } |
| | 86 | |
| | 87 | /** |
| | 88 | * Support for Kindle previews created from the self-service embedding tool |
| | 89 | * |
| | 90 | * @link http://www.amazon.com/kindleinstantpreview Kindle Instant Previews for third parties |
| | 91 | * |
| | 92 | * @ticket 38181 |
| | 93 | */ |
| | 94 | function test_amazon_kindle_embedded_preview_embed() { |
| | 95 | // URL. |
| | 96 | $out = wp_oembed_get( 'https://read.amazon.com/kp/embed?asin=B008TW1HMG&tag=foo-20' ); |
| | 97 | $this->assertContains( 'https://read.amazon.com/kp/card?', $out ); |
| | 98 | $this->assertContains( 'asin=B008TW1HMG', $out ); |
| | 99 | $this->assertContains( 'tag=foo-20', $out ); |
| | 100 | |
| | 101 | // Interactive book card. |
| | 102 | $out = wp_oembed_get( 'https://read.amazon.com/kp/card?asin=B008TW1HMG&tag=foo-20&preview=inline' ); |
| | 103 | $this->assertContains( 'https://read.amazon.com/kp/card?', $out ); |
| | 104 | $this->assertContains( 'asin=B008TW1HMG', $out ); |
| | 105 | $this->assertContains( 'tag=foo-20', $out ); |
| | 106 | } |
| | 107 | |
| | 108 | /** |
| | 109 | * Support for Kindle Instant Previews in non-US marketplaces |
| | 110 | * |
| | 111 | * @ticket 38181 |
| | 112 | */ |
| | 113 | function test_amazon_kindle_preview_non_us_embed() { |
| | 114 | // Canada (canonical TLD: .ca) |
| | 115 | $out = wp_oembed_get( 'https://read.amazon.ca/kp/embed?asin=B008TW1HMG&tag=foo-20&ref_=bar_qux' ); |
| | 116 | $this->assertContains( 'https://read.amazon.ca/kp/card?', $out ); |
| | 117 | $this->assertContains( 'asin=B008TW1HMG', $out ); |
| | 118 | $this->assertContains( 'tag=foo-20', $out ); |
| | 119 | |
| | 120 | // India (canonical TLD: .in) |
| | 121 | $out = wp_oembed_get( 'https://read.amazon.in/kp/embed?asin=B008TW1HMG&tag=foo-20&ref_=bar_qux' ); |
| | 122 | $this->assertContains( 'https://read.amazon.in/kp/card?', $out ); |
| | 123 | $this->assertContains( 'asin=B008TW1HMG', $out ); |
| | 124 | $this->assertContains( 'tag=foo-20', $out ); |
| | 125 | |
| | 126 | // Asia (canonical TLD: .com.au) |
| | 127 | $out = wp_oembed_get( 'https://read.amazon.co.jp/kp/embed?asin=B008TW1HMG&tag=foo-20&ref_=bar_qux&preview=inline' ); |
| | 128 | $this->assertContains( 'https://read.amazon.com.au/kp/card?', $out ); |
| | 129 | $this->assertContains( 'asin=B008TW1HMG', $out ); |
| | 130 | $this->assertContains( 'tag=foo-20', $out ); |
| | 131 | |
| | 132 | // China (canonical TLD: .cn) |
| | 133 | $out = wp_oembed_get( 'https://read.amazon.cn/kp/embed?asin=B01M06TYLV&tag=foo-20&ref_=bar_qux&preview=inline' ); |
| | 134 | $this->assertContains( 'https://read.amazon.cn/kp/card?', $out ); |
| | 135 | $this->assertContains( 'asin=B01M06TYLV', $out ); |
| | 136 | $this->assertContains( 'tag=foo-20', $out ); |
| | 137 | } |
| | 138 | } |