From 86d95139ff7e8485bc74cdfddeaadfca3506f104 Mon Sep 17 00:00:00 2001 From: David Grudl <david@grudl.com> Date: Sun, 12 Jan 2025 22:02:32 +0100 Subject: [PATCH] nette/tester 2.5.5 --- tester/bg/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/cs/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/de/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/el/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/en/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/es/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/fr/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/hu/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/it/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/pl/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/pt/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/ro/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/ru/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/sl/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/tr/helpers.texy | 39 +++++++++++++++++++++++++-------------- tester/uk/helpers.texy | 39 +++++++++++++++++++++++++-------------- 16 files changed, 400 insertions(+), 224 deletions(-) diff --git a/tester/bg/helpers.texy b/tester/bg/helpers.texy index 2f173d8c93..b51da683d3 100644 --- a/tester/bg/helpers.texy +++ b/tester/bg/helpers.texy @@ -4,22 +4,33 @@ DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` е клас, разширяващ `SimpleXMLElement` с методи за улесняване на тестването на HTML или XML съдържание. +`Tester\DomQuery` разширява `SimpleXMLElement` с лесни заявки за HTML или XML с помощта на селектори CSS. ```php -# в $html е низ с HTML документа, а в $dom получаваме кореновия елемент -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# или проверете дали елементът отговаря на селектора (от версия 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/cs/helpers.texy b/tester/cs/helpers.texy index 4027ad0888..fb5c848f02 100644 --- a/tester/cs/helpers.texy +++ b/tester/cs/helpers.texy @@ -4,22 +4,33 @@ Pomocné třídy DomQuery -------- -`Tester\DomQuery` je třída rozšiřující `SimpleXMLElement` o metody usnadňující testování obsahu HTML nebo XML. +`Tester\DomQuery` je třída rozšiřující `SimpleXMLElement` o snadné vyhledávání v HTML nebo XML pomocí CSS selektorů. ```php -# v $html je řetězec s HTML dokumentem, v $dom získáme kořenový element -$dom = Tester\DomQuery::fromHtml($html); - -# můžeme testovat přítomnost elementů podle CSS selektorů -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# nebo vybrat elementy jako pole DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# nebo ověřovat, zda element vyhovuje selektoru (od verze 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# vytvoření DomQuery z HTML řetězce +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test existence elementů pomocí CSS selektorů +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# nalezení elementů jako pole DomQuery objektů +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test, zda element odpovídá selektoru (od verze 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# nalezení nejbližšího předka odpovídajícího selektoru (od 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/de/helpers.texy b/tester/de/helpers.texy index 0451557d1a..881734df40 100644 --- a/tester/de/helpers.texy +++ b/tester/de/helpers.texy @@ -4,22 +4,33 @@ Helfer DomQuery -------- -`Tester\DomQuery` ist eine Klasse, die `SimpleXMLElement` mit Methoden erweitert, die das Testen von HTML- oder XML-Inhalten erleichtern. +`Tester\DomQuery` erweitert `SimpleXMLElement` um eine einfache HTML- oder XML-Abfrage mit CSS-Selektoren. ```php -# $html ist ein String mit dem HTML-Dokument, $dom ist das Root-Element. -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# oder überprüfen, ob das Element mit dem Selektor übereinstimmt (ab Version 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/el/helpers.texy b/tester/el/helpers.texy index 9063fd3527..a0cff07e4b 100644 --- a/tester/el/helpers.texy +++ b/tester/el/helpers.texy @@ -4,22 +4,33 @@ DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` είναι μια κλάση που επεκτείνει το `SimpleXMLElement` με μεθόδους που διευκολύνουν τον έλεγχο περιεχομένου HTML ή XML. +`Tester\DomQuery` επεκτείνει το `SimpleXMLElement` με εύκολη αναζήτηση σε HTML ή XML χρησιμοποιώντας επιλογείς CSS. ```php -# στο $html είναι μια συμβολοσειρά με το έγγραφο HTML, στο $dom παίρνουμε το στοιχείο ρίζα -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# ή να επαληθεύσει ότι το στοιχείο ταιριάζει με τον επιλογέα (από την έκδοση 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/en/helpers.texy b/tester/en/helpers.texy index 937d3c6527..53549a911c 100644 --- a/tester/en/helpers.texy +++ b/tester/en/helpers.texy @@ -4,22 +4,33 @@ Helpers DomQuery -------- -`Tester\DomQuery` is a class that extends `SimpleXMLElement` with methods that make it easier to test HTML or XML content. +`Tester\DomQuery` extends `SimpleXMLElement` with easy HTML or XML querying using CSS selectors. ```php -# in $html is a string with the HTML document, in $dom we get the root element -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# or verify that the element matches the selector (from version 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/es/helpers.texy b/tester/es/helpers.texy index 20f568e17d..5f502f3bb5 100644 --- a/tester/es/helpers.texy +++ b/tester/es/helpers.texy @@ -4,22 +4,33 @@ Ayudantes DomQuery -------- -`Tester\DomQuery` es una clase que amplía `SimpleXMLElement` con métodos que facilitan la comprobación de contenidos HTML o XML. +`Tester\DomQuery` amplía `SimpleXMLElement` con consultas HTML o XML sencillas mediante selectores CSS. ```php -# en $html es una cadena con el documento HTML, en $dom obtenemos el elemento raíz -$dom = Tester\DomQuery::fromHtml($html); - -# podemos comprobar la presencia de elementos utilizando selectores CSS -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# o seleccionar elementos como array de DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# o verificar que el elemento coincide con el selector (a partir de la versión 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/fr/helpers.texy b/tester/fr/helpers.texy index 48ad49c8bf..64290731db 100644 --- a/tester/fr/helpers.texy +++ b/tester/fr/helpers.texy @@ -4,22 +4,33 @@ Aides DomQuery -------- -`Tester\DomQuery` est une classe qui étend `SimpleXMLElement` avec des méthodes qui facilitent le test du contenu HTML ou XML. +`Tester\DomQuery` étend `SimpleXMLElement` en facilitant les requêtes HTML ou XML à l'aide de sélecteurs CSS. ```php -# dans $html est une chaîne avec le document HTML, dans $dom nous obtenons l'élément racine -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# ou vérifier que l'élément correspond au sélecteur (à partir de la version 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/hu/helpers.texy b/tester/hu/helpers.texy index 6312705ce2..dd4acd0d10 100644 --- a/tester/hu/helpers.texy +++ b/tester/hu/helpers.texy @@ -4,22 +4,33 @@ Segítők DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` egy olyan osztály, amely a `SimpleXMLElement` címet bővíti olyan metódusokkal, amelyek megkönnyítik a HTML- vagy XML-tartalom tesztelését. +`Tester\DomQuery` kibővíti a `SimpleXMLElement` oldalt egyszerű HTML vagy XML lekérdezéssel CSS szelektorok segítségével. ```php -# a $html-ben egy karakterlánc a HTML dokumentummal, a $dom-ban pedig a gyökérelemet kapjuk meg. -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# vagy ellenőrizze, hogy az elem megfelel-e a szelektornak (a 2.5.3. verziótól) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/it/helpers.texy b/tester/it/helpers.texy index f9674eb746..b7e89bfb96 100644 --- a/tester/it/helpers.texy +++ b/tester/it/helpers.texy @@ -4,22 +4,33 @@ Aiutanti DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` è una classe che estende `SimpleXMLElement` con metodi che facilitano il test di contenuti HTML o XML. +`Tester\DomQuery` estende `SimpleXMLElement` con una facile interrogazione di HTML o XML tramite selettori CSS. ```php -# in $html c'è una stringa con il documento HTML, in $dom c'è l'elemento root -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# o verificare che l'elemento corrisponda al selettore (dalla versione 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/pl/helpers.texy b/tester/pl/helpers.texy index 87c0d1ab10..8a8937f0de 100644 --- a/tester/pl/helpers.texy +++ b/tester/pl/helpers.texy @@ -4,22 +4,33 @@ Zajęcia pomocnicze DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` jest klasą rozszerzającą `SimpleXMLElement` o metody ułatwiające testowanie zawartości HTML lub XML. +`Tester\DomQuery` rozszerza `SimpleXMLElement` o łatwe odpytywanie HTML lub XML za pomocą selektorów CSS. ```php -# w $html jest łańcuch z dokumentem HTML, w $dom otrzymujemy element główny -$dom = Tester\DomQuery::fromHtml($html); - -# můžeme testovat přítomnost elementů podle CSS selektorů -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# nebo vybrat elementy jako pole DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# lub sprawdzić, czy element pasuje do selektora (od wersji 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/pt/helpers.texy b/tester/pt/helpers.texy index 2fdc8a72b0..eb2034e98c 100644 --- a/tester/pt/helpers.texy +++ b/tester/pt/helpers.texy @@ -4,22 +4,33 @@ Ajudantes DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` é uma classe que se estende `SimpleXMLElement` com métodos que facilitam o teste de conteúdo HTML ou XML. +`Tester\DomQuery` amplia o site `SimpleXMLElement` com consultas fáceis em HTML ou XML usando seletores CSS. ```php -# em $html é uma string com o documento HTML, em $dom obtemos o elemento raiz -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# ou verificar se o elemento corresponde ao seletor (a partir da versão 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/ro/helpers.texy b/tester/ro/helpers.texy index 7f93e9a4df..aa2b23ed2e 100644 --- a/tester/ro/helpers.texy +++ b/tester/ro/helpers.texy @@ -4,22 +4,33 @@ Ajutoarele DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` este o clasă care extinde `SimpleXMLElement` cu metode care facilitează testarea conținutului HTML sau XML. +`Tester\DomQuery` extinde `SimpleXMLElement` cu interogare ușoară HTML sau XML folosind selectori CSS. ```php -# în $html este un șir de caractere cu documentul HTML, în $dom obținem elementul rădăcină -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# sau verifică dacă elementul se potrivește cu selectorul (din versiunea 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/ru/helpers.texy b/tester/ru/helpers.texy index ce17cc0fe1..b783a22dd8 100644 --- a/tester/ru/helpers.texy +++ b/tester/ru/helpers.texy @@ -4,22 +4,33 @@ DomQuery -------- -`Tester\DomQuery` это класс, расширяющий `SimpleXMLElement` с методами, облегчающими тестирование содержимого HTML или XML. +`Tester\DomQuery` Расширяет `SimpleXMLElement`, позволяя легко запрашивать HTML или XML с помощью CSS-селекторов. ```php -# в $html - строка с HTML-документом, в $dom - корневой элемент -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# или проверьте, соответствует ли элемент селектору (начиная с версии 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/sl/helpers.texy b/tester/sl/helpers.texy index 9ca0cf7705..ffe20be248 100644 --- a/tester/sl/helpers.texy +++ b/tester/sl/helpers.texy @@ -4,22 +4,33 @@ Pomočniki DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` je razred, ki razširja `SimpleXMLElement` z metodami, ki olajšajo testiranje vsebine HTML ali XML. +`Tester\DomQuery` razširja `SimpleXMLElement` z enostavnim poizvedovanjem v HTML ali XML z uporabo selektorjev CSS. ```php -# v $html je niz z dokumentom HTML, v $dom dobimo korenski element -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# ali preverite, ali element ustreza izbirniku (od različice 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/tr/helpers.texy b/tester/tr/helpers.texy index dd4834f341..e1f5489ece 100644 --- a/tester/tr/helpers.texy +++ b/tester/tr/helpers.texy @@ -4,22 +4,33 @@ Yardımcılar DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` HTML veya XML içeriğini test etmeyi kolaylaştıran yöntemlerle `SimpleXMLElement` adresini genişleten bir sınıftır. +`Tester\DomQuery` CSS seçicileri kullanarak kolay HTML veya XML sorgulama ile `SimpleXMLElement` adresini genişletir. ```php -# in $html HTML belgesini içeren bir dizedir, $dom içinde kök öğeyi alırız -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# veya öğenin seçiciyle eşleştiğini doğrulayın (2.5.3 sürümünden itibaren) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ``` diff --git a/tester/uk/helpers.texy b/tester/uk/helpers.texy index 36b74139bb..8b6549b1e3 100644 --- a/tester/uk/helpers.texy +++ b/tester/uk/helpers.texy @@ -4,22 +4,33 @@ DomQuery .[#toc-domquery] ------------------------- -`Tester\DomQuery` це клас, що розширює `SimpleXMLElement` з методами, які полегшують тестування вмісту HTML або XML. +`Tester\DomQuery` розширює `SimpleXMLElement` за допомогою простих запитів у форматі HTML або XML за допомогою селекторів CSS. ```php -# в $html знаходиться рядок з HTML-документом, в $dom ми отримуємо кореневий елемент -$dom = Tester\DomQuery::fromHtml($html); - -# we can test the presence of elements using CSS selectors -Assert::true($dom->has('form#registration')); -Assert::true($dom->has('input[name="username"]')); -Assert::true($dom->has('input[type="submit"]')); - -# or select elements as array of DomQuery -$elems = $dom->find('input[data-autocomplete]'); - -# або перевірка відповідності елемента селектору (починаючи з версії 2.5.3) -Assert::true($elems[0]->matches('[type="submit"]')); +# create DomQuery from HTML string +$dom = Tester\DomQuery::fromHtml(' + <article class="post"> + <h1>Title</h1> + <div class="content">Text</div> + </article> +'); + +# test element existence using CSS selectors +Assert::true($dom->has('article.post')); +Assert::true($dom->has('h1')); + +# find elements as DomQuery array +$headings = $dom->find('h1'); +Assert::same('Title', (string) $headings[0]); + +# test if element matches selector (since version 2.5.3) +$content = $dom->find('.content')[0]; +Assert::true($content->matches('div')); +Assert::false($content->matches('p')); + +# find closest ancestor matching selector (since 2.5.5) +$article = $content->closest('.post'); +Assert::true($article->matches('article')); ```