|
3 | 3 | namespace Tests\Localized; |
4 | 4 |
|
5 | 5 | use Statamic\Facades\Config; |
| 6 | +use Statamic\Facades\Entry; |
6 | 7 | use Tests\TestCase; |
7 | 8 | use Tests\ViewScenarios; |
8 | 9 |
|
@@ -141,4 +142,97 @@ public function it_doesnt_generate_multisite_meta_for_excluded_sites($viewType) |
141 | 142 | $this->assertStringNotContainsString('content="fr_FR"', $content); |
142 | 143 | $this->assertStringNotContainsString('hreflang="fr"', $content); |
143 | 144 | } |
| 145 | + |
| 146 | + /** |
| 147 | + * @test |
| 148 | + * @dataProvider viewScenarioProvider |
| 149 | + */ |
| 150 | + public function it_doesnt_generate_multisite_meta_for_unpublished_content($viewType) |
| 151 | + { |
| 152 | + $this->prepareViews($viewType); |
| 153 | + |
| 154 | + Entry::find('62136fa2-9e5c-4c38-a894-a2753f02f5ff')->in('french')->unpublish()->save(); |
| 155 | + |
| 156 | + $expectedOgLocaleMeta = <<<'EOT' |
| 157 | +<meta property="og:locale" content="en_US" /> |
| 158 | +<meta property="og:locale:alternate" content="it_IT" /> |
| 159 | +EOT; |
| 160 | + |
| 161 | + $expectedAlternateHreflangMeta = <<<'EOT' |
| 162 | +<link rel="alternate" href="http://cool-runnings.com/about" hreflang="en" /> |
| 163 | +<link rel="alternate" href="http://cool-runnings.com/it/about" hreflang="it" /> |
| 164 | +EOT; |
| 165 | + |
| 166 | + $content = $this->get('/about')->content(); |
| 167 | + |
| 168 | + $this->assertStringContainsString("<h1>{$viewType}</h1>", $content); |
| 169 | + $this->assertStringContainsString($expectedOgLocaleMeta, $content); |
| 170 | + $this->assertStringContainsString($expectedAlternateHreflangMeta, $content); |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * @test |
| 175 | + * @dataProvider viewScenarioProvider |
| 176 | + */ |
| 177 | + public function it_doesnt_generate_multisite_meta_for_scheduled_content($viewType) |
| 178 | + { |
| 179 | + $this->prepareViews($viewType); |
| 180 | + |
| 181 | + $entry = Entry::find('62136fa2-9e5c-4c38-a894-a2753f02f5ff'); |
| 182 | + |
| 183 | + $collection = $entry->collection()->dated(true)->futureDateBehavior('private')->save(); |
| 184 | + |
| 185 | + $entry->in('default')->date(now()->subDays(5))->save(); |
| 186 | + $entry->in('french')->date(now()->addDays(3))->save(); // This entry is scheduled, should not show |
| 187 | + $entry->in('italian')->date(now()->subDays(5))->save(); |
| 188 | + |
| 189 | + $expectedOgLocaleMeta = <<<'EOT' |
| 190 | +<meta property="og:locale" content="en_US" /> |
| 191 | +<meta property="og:locale:alternate" content="it_IT" /> |
| 192 | +EOT; |
| 193 | + |
| 194 | + $expectedAlternateHreflangMeta = <<<'EOT' |
| 195 | +<link rel="alternate" href="http://cool-runnings.com/about" hreflang="en" /> |
| 196 | +<link rel="alternate" href="http://cool-runnings.com/it/about" hreflang="it" /> |
| 197 | +EOT; |
| 198 | + |
| 199 | + $content = $this->get('/about')->content(); |
| 200 | + |
| 201 | + $this->assertStringContainsString("<h1>{$viewType}</h1>", $content); |
| 202 | + $this->assertStringContainsString($expectedOgLocaleMeta, $content); |
| 203 | + $this->assertStringContainsString($expectedAlternateHreflangMeta, $content); |
| 204 | + } |
| 205 | + |
| 206 | + /** |
| 207 | + * @test |
| 208 | + * @dataProvider viewScenarioProvider |
| 209 | + */ |
| 210 | + public function it_doesnt_generate_multisite_meta_for_expired_content($viewType) |
| 211 | + { |
| 212 | + $this->prepareViews($viewType); |
| 213 | + |
| 214 | + $entry = Entry::find('62136fa2-9e5c-4c38-a894-a2753f02f5ff'); |
| 215 | + |
| 216 | + $collection = $entry->collection()->dated(true)->pastDateBehavior('private')->save(); |
| 217 | + |
| 218 | + $entry->in('default')->date(now()->addDays(5))->save(); |
| 219 | + $entry->in('french')->date(now()->subDays(3))->save(); // This entry is expired, should not show |
| 220 | + $entry->in('italian')->date(now()->addDays(5))->save(); |
| 221 | + |
| 222 | + $expectedOgLocaleMeta = <<<'EOT' |
| 223 | +<meta property="og:locale" content="en_US" /> |
| 224 | +<meta property="og:locale:alternate" content="it_IT" /> |
| 225 | +EOT; |
| 226 | + |
| 227 | + $expectedAlternateHreflangMeta = <<<'EOT' |
| 228 | +<link rel="alternate" href="http://cool-runnings.com/about" hreflang="en" /> |
| 229 | +<link rel="alternate" href="http://cool-runnings.com/it/about" hreflang="it" /> |
| 230 | +EOT; |
| 231 | + |
| 232 | + $content = $this->get('/about')->content(); |
| 233 | + |
| 234 | + $this->assertStringContainsString("<h1>{$viewType}</h1>", $content); |
| 235 | + $this->assertStringContainsString($expectedOgLocaleMeta, $content); |
| 236 | + $this->assertStringContainsString($expectedAlternateHreflangMeta, $content); |
| 237 | + } |
144 | 238 | } |
0 commit comments