Skip to content

Commit

Permalink
Unit tests that need to pass for issue 49
Browse files Browse the repository at this point in the history
  • Loading branch information
jakejackson1 committed Mar 21, 2024
1 parent a9da950 commit d12d8b4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/Issues/Issue49Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace QueryPathTests;

class Issue49Test extends TestCase
{
public function testCheckingForMatchingTextInputs(): void
{
$q = html5qp('<div><input name="text1" type="text" /><input name="text2" /></div>', 'div');

/* Check if the DOMNode or its children matches */
$this->assertTrue($q->is(':text'));
$this->assertCount(2, $q->find(':text'));

$textNode = $q->find('div')->contents()->eq(0);
$this->assertTrue($textNode->is(':text'));
}

public function testCheckingForEmptyTextInputs(): void
{
$q = html5qp('<div>Sample</div>', 'div');

/* Check if the DOMNode or its children matches */
$this->assertFalse($q->is(':text'));
$this->assertCount(0, $q->find(':text'));

/* check if a text node matches */
$textNode = $q->find('div')->contents()->eq(0);
$this->assertFalse($textNode->is(':text'));
}
}

0 comments on commit d12d8b4

Please sign in to comment.