Release diogenes-0.9.22
[diogenes.git] / testing / assert.patch
CommitLineData
6855525e
JL
1--- Assert.php.orig 2004-06-09 15:52:13.000000000 +1000
2+++ Assert.php 2004-06-09 15:55:10.000000000 +1000
3@@ -240,6 +240,89 @@
4 }
5
6 /**
7+ * Asserts that the actual string does not match a given
8+ * regular expression.
9+ *
10+ * @param string
11+ * @param string
12+ * @param string
13+ * @access public
14+ * @author Sébastien Hordeaux <marms@marms.com>
15+ * @author Matthew Palmer <mpalmer@hezmatt.org>
16+ */
17+ function assertNotRegExp($expected, $actual, $message = '') {
18+ $message = sprintf(
19+ '%sexpected %s, actual %s',
20+
21+ !empty($message) ? $message . ' ' : '',
22+ $expected,
23+ $actual
24+ );
25+
26+ if (preg_match($expected, $actual)) {
27+ return $this->fail($message);
28+ }
29+ }
30+
31+ /**
32+ * Asserts that the expected string is contained somewhere within the
33+ * data string given.
34+ *
35+ * @param string
36+ * @param string
37+ * @param string
38+ * @access public
39+ * @author Matthew Palmer <mpalmer@hezmatt.org>
40+ */
41+ function assertSubStr($needle, $haystack, $message = '')
42+ {
43+ if (empty($message))
44+ {
45+ $message = sprintf(
46+ '"%s" not found in "%s"',
47+ $expected,
48+ $actual
49+ );
50+ }
51+
52+ if (substr_count($haystack, $needle) == 0)
53+ {
54+ return $this->fail($message);
55+ }
56+
57+ return $this->pass();
58+ }
59+
60+ /**
61+ * Asserts that the expected string is not contained anywhere within the
62+ * data string given.
63+ *
64+ * @param string
65+ * @param string
66+ * @param string
67+ * @access public
68+ * @author Matthew Palmer <mpalmer@hezmatt.org>
69+ */
70+ function assertNotSubStr($needle, $haystack, $message = '')
71+ {
72+ if (empty($message))
73+ {
74+ $message = sprintf(
75+ '"%s" found in "%s"',
76+ $expected,
77+ $actual
78+ );
79+ }
80+
81+ if (substr_count($haystack, $needle) > 0)
82+ {
83+ return $this->fail($message);
84+ }
85+
86+ return $this->pass();
87+ }
88+
89+ /**
90 * Asserts that a variable is of a given type.
91 *
92 * @param string $expected