1--TEST-- 2CSS Selectors - Pseudo classes: nth-child 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8require __DIR__ . '/test_utils.inc'; 9 10$dom = DOM\XMLDocument::createFromString(<<<XML 11<container> 12 <h2>1</h2> 13 <h2>2</h2> 14 <h2>3</h2> 15 <h2>4</h2> 16 <h2>5</h2> 17</container> 18XML); 19 20test_helper($dom, 'h2:nth-of-type(n+2):nth-last-of-type(n+2)'); 21test_helper($dom, 'h2:not(:first-of-type):not(:last-of-type)'); // Equivalent to the above 22test_helper($dom, 'h2:nth-child(2)'); 23test_helper($dom, 'h2:nth-last-child(2)'); 24test_helper($dom, 'h2:nth-child(2n + 1)'); 25test_helper($dom, 'h2:nth-last-child(2n + 1)'); 26test_helper($dom, 'h2:nth-child(3n - 2)'); 27test_helper($dom, 'h2:nth-last-child(3n - 2)'); 28 29?> 30--EXPECT-- 31--- Selector: h2:nth-of-type(n+2):nth-last-of-type(n+2) --- 32<h2>2</h2> 33<h2>3</h2> 34<h2>4</h2> 35--- Selector: h2:not(:first-of-type):not(:last-of-type) --- 36<h2>2</h2> 37<h2>3</h2> 38<h2>4</h2> 39--- Selector: h2:nth-child(2) --- 40<h2>2</h2> 41--- Selector: h2:nth-last-child(2) --- 42<h2>4</h2> 43--- Selector: h2:nth-child(2n + 1) --- 44<h2>1</h2> 45<h2>3</h2> 46<h2>5</h2> 47--- Selector: h2:nth-last-child(2n + 1) --- 48<h2>1</h2> 49<h2>3</h2> 50<h2>5</h2> 51--- Selector: h2:nth-child(3n - 2) --- 52<h2>1</h2> 53<h2>4</h2> 54--- Selector: h2:nth-last-child(3n - 2) --- 55<h2>2</h2> 56<h2>5</h2> 57