mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
Add tests from testfest
This commit is contained in:
parent
5aa7732d2f
commit
fa3ae04c28
3 changed files with 90 additions and 0 deletions
26
ext/spl/tests/regexIterator_flags_basic.phpt
Normal file
26
ext/spl/tests/regexIterator_flags_basic.phpt
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
--TEST--
|
||||||
|
SPL: RegexIterator::getFlags() and setFlags() basic tests
|
||||||
|
--SKIPIF--
|
||||||
|
<?php extension_loaded('spl') or die('skip'); ?>
|
||||||
|
--CREDITS--
|
||||||
|
Felix De Vliegher <felix.devliegher@gmail.com>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$array = array('foo', 'bar', 'baz');
|
||||||
|
$iterator = new ArrayIterator($array);
|
||||||
|
$regexIterator = new RegexIterator($iterator, "/f/", null, RegexIterator::USE_KEY);
|
||||||
|
|
||||||
|
var_dump($regexIterator->getFlags() === RegexIterator::USE_KEY);
|
||||||
|
|
||||||
|
// Test a change in flags, there's only one class constant so it has to be another int value
|
||||||
|
$regexIterator->setFlags(3);
|
||||||
|
var_dump($regexIterator->getFlags() === RegexIterator::USE_KEY);
|
||||||
|
$regexIterator->setFlags(RegexIterator::USE_KEY);
|
||||||
|
var_dump($regexIterator->getFlags() === RegexIterator::USE_KEY);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
34
ext/spl/tests/regexIterator_mode_basic.phpt
Normal file
34
ext/spl/tests/regexIterator_mode_basic.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
SPL: RegexIterator::getMode() and setMode() basic tests
|
||||||
|
--SKIPIF--
|
||||||
|
<?php extension_loaded('spl') or die('skip'); ?>
|
||||||
|
--CREDITS--
|
||||||
|
Felix De Vliegher <felix.devliegher@gmail.com>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$array = array('foo', 'bar', 'baz');
|
||||||
|
$iterator = new ArrayIterator($array);
|
||||||
|
$regexIterator = new RegexIterator($iterator, "/f/");
|
||||||
|
|
||||||
|
var_dump($regexIterator->getMode() === RegexIterator::MATCH);
|
||||||
|
|
||||||
|
$regexIterator->setMode(RegexIterator::MATCH);
|
||||||
|
var_dump($regexIterator->getMode() === RegexIterator::MATCH);
|
||||||
|
|
||||||
|
$regexIterator->setMode(RegexIterator::GET_MATCH);
|
||||||
|
var_dump($regexIterator->getMode() === RegexIterator::GET_MATCH);
|
||||||
|
|
||||||
|
$regexIterator->setMode(RegexIterator::ALL_MATCHES);
|
||||||
|
var_dump($regexIterator->getMode() === RegexIterator::ALL_MATCHES);
|
||||||
|
|
||||||
|
$regexIterator->setMode(RegexIterator::SPLIT);
|
||||||
|
var_dump($regexIterator->getMode() === RegexIterator::SPLIT);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
30
ext/spl/tests/regexIterator_setMode_error.phpt
Normal file
30
ext/spl/tests/regexIterator_setMode_error.phpt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
--TEST--
|
||||||
|
SPL: RegexIterator::setMode() error tests
|
||||||
|
--SKIPIF--
|
||||||
|
<?php extension_loaded('spl') or die('skip'); ?>
|
||||||
|
--CREDITS--
|
||||||
|
Felix De Vliegher <felix.devliegher@gmail.com>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$array = array('foo', 'bar', 'baz');
|
||||||
|
$regexIterator = new RegexIterator(new ArrayIterator($array), "/f/");
|
||||||
|
|
||||||
|
var_dump($regexIterator->getMode());
|
||||||
|
|
||||||
|
try {
|
||||||
|
$regexIterator->setMode(7);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
var_dump($e->getMessage());
|
||||||
|
var_dump($e->getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
$regexIterator->setMode('foo');
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
int(0)
|
||||||
|
string(14) "Illegal mode 7"
|
||||||
|
int(0)
|
||||||
|
|
||||||
|
Warning: RegexIterator::setMode() expects parameter 1 to be long, string given in %s on line %d
|
Loading…
Add table
Add a link
Reference in a new issue