Skip to content

Commit

Permalink
Merge pull request #1256 from sjinks/tests
Browse files Browse the repository at this point in the history
Regression Tests
  • Loading branch information
Phalcon committed Sep 20, 2013
2 parents b97aef3 + a4610ab commit 4c85e87
Show file tree
Hide file tree
Showing 24 changed files with 415 additions and 4 deletions.
1 change: 1 addition & 0 deletions build/32bits/tests
1 change: 1 addition & 0 deletions build/64bits/tests
1 change: 1 addition & 0 deletions build/safe/tests
2 changes: 2 additions & 0 deletions ext/tests/config/1024-a.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[a]
a_1 = 1
2 changes: 2 additions & 0 deletions ext/tests/config/1024-b.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[a]
a_2 = 1
20 changes: 20 additions & 0 deletions ext/tests/issue-1000.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Phalcon + PHP-FPM = segfault - https://github.com/phalcon/cphalcon/issues/1000
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
class Issue1000 extends \Phalcon\Config
{
private $_section;

public function __construct($file, $section = null)
{
$this->_section = $section;
}
}

$t1 = new Issue1000('test');
$t2 = new Issue1000('test', 'test');
?>
--EXPECT--
16 changes: 16 additions & 0 deletions ext/tests/issue-1018.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Phalcon\Element::addFilter() prepends inserts NULL as the first element - https://github.com/phalcon/cphalcon/issues/1018
--SKIPIF--
<?php include('skipif.inc');
--FILE--
<?php
$di = new \Phalcon\DI\FactoryDefault();
$form = new \Phalcon\Forms\Form();
$email = new \Phalcon\Forms\Element\Text('email');
$email->addValidator(new \Phalcon\Validation\Validator\Email());
$email->addFilter('trim');
$form->add($email);
$data = array('email' => '[email protected]');
assert($form->isValid($data));
?>
--EXPECT--
21 changes: 21 additions & 0 deletions ext/tests/issue-1024.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Phalcon\Config::merge does not work with derived classes - https://github.com/phalcon/cphalcon/issues/1024
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$config1 = new \Phalcon\Config\Adapter\Ini(__DIR__ . '/config/1024-a.ini');
$config2 = new \Phalcon\Config\Adapter\Ini(__DIR__ . '/config/1024-b.ini');
$config1->merge($config2);
print_r($config1->toArray());
?>
--EXPECT--
Array
(
[a] => Array
(
[a_1] => 1
[a_2] => 1
)

)
17 changes: 17 additions & 0 deletions ext/tests/issue-1029.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Phalcon\Forms\Form::label() extra param - https://github.com/phalcon/cphalcon/issues/1029
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$form = new \Phalcon\Forms\Form();
$form->add(new \Phalcon\Forms\Element\Text("name"));
$telephone = new \Phalcon\Forms\Element\Text("telephone");
$telephone->setLabel("The Telephone");
$form->add($telephone);
echo $form->label('name', array('class' => 'form-control')), PHP_EOL;
echo $form->label('telephone', array('class' => 'form-control')), PHP_EOL;
?>
--EXPECT--
<label for="name" class="form-control">name</label>
<label for="telephone" class="form-control">The Telephone</label>
14 changes: 14 additions & 0 deletions ext/tests/issue-1091.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Phalcon\Http\Request::getRawBody() empties the raw body content - https://github.com/phalcon/cphalcon/issues/1091
--SKIPIF--
<?php include('skipif.inc'); ?>
--POST--
{"query":[["george","alan", "thomas"]]}
--FILE--
<?php
$request = new \Phalcon\Http\Request();
var_dump($request->getRawBody(), $request->getRawBody());
?>
--EXPECT--
string(39) "{"query":[["george","alan", "thomas"]]}"
string(39) "{"query":[["george","alan", "thomas"]]}"
12 changes: 12 additions & 0 deletions ext/tests/issue-1099.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
\Phalcon\Debug and russian language - https://github.com/phalcon/cphalcon/issues/1099
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$d = new \Phalcon\Debug();
$d->listen(true, true);
throw new \Exception('Тест');
?>
--EXPECTREGEX--
^.*?<meta http-equiv="Content-Type" content="text\/html; charset=utf-8"\/>.*$
46 changes: 46 additions & 0 deletions ext/tests/issue-1175.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--TEST--
Use recommended reason phrases for redirect - https://github.com/phalcon/cphalcon/issues/1175
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$di = new \Phalcon\DI\FactoryDefault();
$response = new \Phalcon\Http\Response();
$response->setDI($di);

$response->resetHeaders();
$response->redirect("some/local/uri");
$h = $response->getHeaders();
echo $h->get('Status'), PHP_EOL;

$response->resetHeaders();
$response->redirect("http://google.com", true);
$h = $response->getHeaders();
echo $h->get('Status'), PHP_EOL;

$response->resetHeaders();
$response->redirect("http://google.com", true, 301);
$h = $response->getHeaders();
echo $h->get('Status'), PHP_EOL;

for ($i=300; $i<310; ++$i) {
$response->resetHeaders();
$response->redirect("http://google.com", true, $i);
$h = $response->getHeaders();
echo $h->get('Status'), PHP_EOL;
}
?>
--EXPECT--
302 Found
302 Found
301 Moved Permanently
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
306 Switch Proxy
307 Temporary Redirect
308 Permanent Redirect
309 Redirect
14 changes: 14 additions & 0 deletions ext/tests/issue-1190.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Form.render doesn't escape value attributes on TextFields - https://github.com/phalcon/cphalcon/issues/1190
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$object = new stdClass();
$object->title = 'Hello "world!"';
$form = new \Phalcon\Forms\Form($object);
$form->add(new \Phalcon\Forms\Element\Text("title"));
echo $form->render('title'), PHP_EOL;
?>
--EXPECT--
<input type="text" value="Hello &quot;world!&quot;" name="title" id="title" />
2 changes: 1 addition & 1 deletion ext/tests/issue-1210.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Crash while rendering element's label - https://github.com/phalcon/cphalcon/issues/1210
--SKIPIF--
<?php if (!extension_loaded("phalcon")) print "skip"; ?>
<?php include('skipif.inc'); ?>
--FILE--
<?php
$e = new \Phalcon\Forms\Element\Text('test');
Expand Down
2 changes: 1 addition & 1 deletion ext/tests/issue-1216.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
XSS - https://github.com/phalcon/cphalcon/issues/1216
--SKIPIF--
<?php if (!extension_loaded("phalcon")) print "skip"; ?>
<?php include('skipif.inc'); ?>
--FILE--
<?php
$di = new \Phalcon\DI\FactoryDefault();
Expand Down
2 changes: 1 addition & 1 deletion ext/tests/issue-1243.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Phalcon\Mvc\Model\Validator\Email validates malformed emails as correct - https://github.com/phalcon/cphalcon/issues/1243
--SKIPIF--
<?php if (!extension_loaded("phalcon")) die("skip"); ?>
<?php include('skipif.inc'); ?>
--FILE--
<?php
class FakeModel
Expand Down
154 changes: 154 additions & 0 deletions ext/tests/issue-731.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
--TEST--
Possibly Incorrect Behavior of Phalcon\Config::merge() - https://github.com/phalcon/cphalcon/issues/731
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$a = new \Phalcon\Config(array('aaa' => array('b' => 2, 'c' => 3)));
$b = new \Phalcon\Config(array('aaa' => array('a' => 10, 'c' => 30, 'd' => 40)));
$c = array('aaa' => array('b' => 2, 'c' => 30, 'a' => 10, 'd' => 40));
$a->merge($b);
print_r($a->toArray());
print_r($c);
echo PHP_EOL;

$a = new \Phalcon\Config(array('aab' => (object)array('n' => 'm')));
$b = new \Phalcon\Config(array('aab' => array('x' => 'y')));
$c = array('aab' => array('x' => 'y'));
$a->merge($b);
print_r($a->toArray());
print_r($c);
echo PHP_EOL;

$a = new \Phalcon\Config(array('ab' => array('b' => 1, 'c' => 2)));
$b = new \Phalcon\Config(array('ab' => array(0 => -10, 'c' => 20, 'd' => 30)));
$c = array('ab' => array(0 => -10, 'c' => 2, 'd' => 30, 'b' => 1));
$b->merge($a);
print_r($a->toArray());
print_r($c);
echo PHP_EOL;

$a = new \Phalcon\Config(array('ac' => array('b' => 1, 'c' => 2)));
$b = new \Phalcon\Config(array('ac' => array(0 => -10, 'c' => 20, 'd' => 30)));
$c = array('ac' => array(0 => -10, 'c' => 20, 'd' => 30, 'b' => 1));
$a->merge($b);
print_r($a->toArray());
print_r($c);
echo PHP_EOL;

$a = new \Phalcon\Config(array('ad' => array(0 => 1, 1 => 2, 2 => 3)));
$b = new \Phalcon\Config(array('ad' => array(1 => 20, 3 => 40)));
$c = array('ad' => array(0 => 1, 1 => 20, 2 => 3, 3 => 40));
$a->merge($b);
print_r($a->toArray());
print_r($c);
echo PHP_EOL;
?>
--EXPECT--
Array
(
[aaa] => Array
(
[b] => 2
[c] => 30
[a] => 10
[d] => 40
)

)
Array
(
[aaa] => Array
(
[b] => 2
[c] => 30
[a] => 10
[d] => 40
)

)

Array
(
[aab] => Array
(
[x] => y
)

)
Array
(
[aab] => Array
(
[x] => y
)

)

Array
(
[ab] => Array
(
[b] => 1
[c] => 2
)

)
Array
(
[ab] => Array
(
[0] => -10
[c] => 2
[d] => 30
[b] => 1
)

)

Array
(
[ac] => Array
(
[b] => 1
[c] => 20
[0] => -10
[d] => 30
)

)
Array
(
[ac] => Array
(
[0] => -10
[c] => 20
[d] => 30
[b] => 1
)

)

Array
(
[ad] => Array
(
[0] => 1
[1] => 20
[2] => 3
[3] => 40
)

)
Array
(
[ad] => Array
(
[0] => 1
[1] => 20
[2] => 3
[3] => 40
)

)

12 changes: 12 additions & 0 deletions ext/tests/issue-732.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Phalcon\Config::offsetUnset() does not work - https://github.com/phalcon/cphalcon/issues/732
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$a = new Phalcon\Config(array('a' => 0));
assert(isset($a['a']));
unset($a['a']);
assert(!isset($a['a']));
?>
--EXPECT--
2 changes: 1 addition & 1 deletion ext/tests/issue-905.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
ACL inheritance is broken in 1.2.X - https://github.com/phalcon/cphalcon/issues/905
--SKIPIF--
<?php //include('skipif.inc'); ?>
<?php include('skipif.inc'); ?>
--FILE--
<?php
$acl = new \Phalcon\Acl\Adapter\Memory();
Expand Down
11 changes: 11 additions & 0 deletions ext/tests/issue-927.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Invalid memory reads when GC is on - https://github.com/phalcon/cphalcon/pull/927
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$config = new \Phalcon\Config(array('test1' => 1, 'test2' => 2));
$config->merge(new \Phalcon\Config(array('test2')));
gc_collect_cycles();
?>
--EXPECT--
Loading

0 comments on commit 4c85e87

Please sign in to comment.