Skip to content

Commit

Permalink
Convert Heredoc to Nowdoc syntax where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Jun 10, 2021
1 parent 882c1a8 commit 099fda5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 56 deletions.
10 changes: 5 additions & 5 deletions tests/system/API/ResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testNoFormatterJSON()
$this->assertEquals('A Custom Reason', $this->response->getReason());
$this->assertEquals(201, $this->response->getStatusCode());

$expected = <<<EOH
$expected = <<<'EOH'
{
"id": 3
}
Expand All @@ -124,7 +124,7 @@ public function testAssociativeArrayPayload()
$this->formatter = null;
$controller = $this->makeController();
$payload = ['answer' => 42];
$expected = <<<EOH
$expected = <<<'EOH'
{
"answer": 42
}
Expand All @@ -142,7 +142,7 @@ public function testArrayPayload()
2,
3,
];
$expected = <<<EOH
$expected = <<<'EOH'
[
1,
2,
Expand All @@ -160,7 +160,7 @@ public function testPHPtoArrayPayload()
$payload = new stdClass();
$payload->name = 'Tom';
$payload->id = 1;
$expected = <<<EOH
$expected = <<<'EOH'
{
"name": "Tom",
"id": 1
Expand Down Expand Up @@ -479,7 +479,7 @@ public function testXMLFormatter()
$this->assertEquals('CodeIgniter\Format\XMLFormatter', get_class($this->formatter));

$controller->respondCreated(['id' => 3], 'A Custom Reason');
$expected = <<<EOH
$expected = <<<'EOH'
<?xml version="1.0"?>
<response><id>3</id></response>

Expand Down
12 changes: 6 additions & 6 deletions tests/system/Format/XMLFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testBasicXML()
'foo' => 'bar',
];

$expected = <<<EOH
$expected = <<<'EOH'
<?xml version="1.0"?>
<response><foo>bar</foo></response>

Expand All @@ -36,7 +36,7 @@ public function testFormatXMLWithMultilevelArray()
'foo' => ['bar'],
];

$expected = <<<EOH
$expected = <<<'EOH'
<?xml version="1.0"?>
<response><foo><item0>bar</item0></foo></response>

Expand All @@ -51,7 +51,7 @@ public function testFormatXMLWithMultilevelArrayAndNumericKey()
['foo'],
];

$expected = <<<EOH
$expected = <<<'EOH'
<?xml version="1.0"?>
<response><item0><item0>foo</item0></item0></response>

Expand All @@ -63,7 +63,7 @@ public function testFormatXMLWithMultilevelArrayAndNumericKey()
public function testStringFormatting()
{
$data = ['Something'];
$expected = <<<EOH
$expected = <<<'EOH'
<?xml version="1.0"?>
<response><item0>Something</item0></response>

Expand All @@ -78,7 +78,7 @@ public function testValidatingXmlTags()
'BBB096630BD' => 'foo',
'096630FR' => 'bar',
];
$expected = <<<EOH
$expected = <<<'EOH'
<?xml version="1.0"?>
<response><BBB096630BD>foo</BBB096630BD><item096630FR>bar</item096630FR></response>

Expand Down Expand Up @@ -171,7 +171,7 @@ public function testDeepNestedArrayToXml()
];

// do not change to tabs!!
$expectedXML = <<<EOF
$expectedXML = <<<'EOF'
<?xml version="1.0"?>
<response>
<data>
Expand Down
44 changes: 22 additions & 22 deletions tests/system/Helpers/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testFormOpenBasic()
EOH;
} else {
$expected = <<<EOH
$expected = <<<'EOH'
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">

EOH;
Expand All @@ -62,7 +62,7 @@ public function testFormOpenHasLocale()
$request->uri = new URI('http://example.com/');

Services::injectMock('request', $request);
$expected = <<<EOH
$expected = <<<'EOH'
<form action="http://example.com/index.php/en/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">

EOH;
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testFormOpenWithoutAction()
EOH;
} else {
$expected = <<<EOH
$expected = <<<'EOH'
<form action="http://example.com/index.php" name="form" id="form" method="POST" accept-charset="utf-8">

EOH;
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testFormOpenWithoutMethod()
EOH;
} else {
$expected = <<<EOH
$expected = <<<'EOH'
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="post" accept-charset="utf-8">

EOH;
Expand Down Expand Up @@ -165,7 +165,7 @@ public function testFormOpenWithHidden()
EOH;
} else {
$expected = <<<EOH
$expected = <<<'EOH'
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">
<input type="hidden" name="foo" value="bar" />
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testFormOpenMultipart()
EOH;
} else {
$expected = <<<EOH
$expected = <<<'EOH'
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" enctype="multipart/form-data" accept-charset="utf-8">

EOH;
Expand Down Expand Up @@ -238,7 +238,7 @@ public function testFormHiddenArrayInput()
$data = [
'foo' => 'bar',
];
$expected = <<<EOH
$expected = <<<'EOH'
<input type="hidden" name="foo" value="bar" />

Expand All @@ -252,7 +252,7 @@ public function testFormHiddenArrayValues()
$data = [
'foo' => 'bar',
];
$expected = <<<EOH
$expected = <<<'EOH'
<input type="hidden" name="name[foo]" value="bar" />

Expand Down Expand Up @@ -327,7 +327,7 @@ public function testFormTextareaWithValueAttribute()
'name' => 'foo',
'value' => 'bar',
];
$expected = <<<EOH
$expected = <<<'EOH'
<textarea name="foo" cols="40" rows="10">bar</textarea>

EOH;
Expand Down Expand Up @@ -472,7 +472,7 @@ public function testFormDropdownInferred()
// ------------------------------------------------------------------------
public function testFormDropdownWithSelectedAttribute()
{
$expected = <<<EOH
$expected = <<<'EOH'
<select name="foo">
<option value="bar" selected="selected">Bar</option>
</select>
Expand All @@ -491,7 +491,7 @@ public function testFormDropdownWithSelectedAttribute()
// ------------------------------------------------------------------------
public function testFormDropdownWithOptionsAttribute()
{
$expected = <<<EOH
$expected = <<<'EOH'
<select name="foo">
<option value="bar">Bar</option>
</select>
Expand All @@ -509,7 +509,7 @@ public function testFormDropdownWithOptionsAttribute()
// ------------------------------------------------------------------------
public function testFormDropdownWithEmptyArrayOptionValue()
{
$expected = <<<EOH
$expected = <<<'EOH'
<select name="foo">
</select>

Expand Down Expand Up @@ -583,7 +583,7 @@ public function testFormFieldset()
// ------------------------------------------------------------------------
public function testFormFieldsetWithNoLegent()
{
$expected = <<<EOH
$expected = <<<'EOH'
<fieldset>

EOH;
Expand All @@ -596,7 +596,7 @@ public function testFormFieldsetWithAttributes()
$attributes = [
'name' => 'bar',
];
$expected = <<<EOH
$expected = <<<'EOH'
<fieldset name="bar">
<legend>Foo</legend>

Expand All @@ -607,7 +607,7 @@ public function testFormFieldsetWithAttributes()
// ------------------------------------------------------------------------
public function testFormFieldsetClose()
{
$expected = <<<EOH
$expected = <<<'EOH'
</fieldset></div></div>
EOH;
$this->assertEquals($expected, form_fieldset_close('</div></div>'));
Expand All @@ -630,7 +630,7 @@ public function testFormCheckboxArrayData()
'value' => 'bar',
'checked' => true,
];
$expected = <<<EOH
$expected = <<<'EOH'
<input type="checkbox" name="foo" value="bar" checked="checked" />

EOH;
Expand All @@ -645,7 +645,7 @@ public function testFormCheckboxArrayDataWithCheckedFalse()
'value' => 'bar',
'checked' => false,
];
$expected = <<<EOH
$expected = <<<'EOH'
<input type="checkbox" name="foo" value="bar" />

EOH;
Expand Down Expand Up @@ -673,7 +673,7 @@ public function testFormSubmit()
// ------------------------------------------------------------------------
public function testFormLabel()
{
$expected = <<<EOH
$expected = <<<'EOH'
<label for="username">What is your Name</label>
EOH;
$this->assertEquals($expected, form_label('What is your Name', 'username'));
Expand All @@ -685,7 +685,7 @@ public function testFormLabelWithAttributes()
$attributes = [
'id' => 'label1',
];
$expected = <<<EOH
$expected = <<<'EOH'
<label for="foo" id="label1">bar</label>
EOH;
$this->assertEquals($expected, form_label('bar', 'foo', $attributes));
Expand Down Expand Up @@ -716,7 +716,7 @@ public function testFormButtonWithDataArray()
'name' => 'foo',
'content' => 'bar',
];
$expected = <<<EOH
$expected = <<<'EOH'
<button name="foo" type="button">bar</button>

EOH;
Expand All @@ -726,7 +726,7 @@ public function testFormButtonWithDataArray()
// ------------------------------------------------------------------------
public function testFormClose()
{
$expected = <<<EOH
$expected = <<<'EOH'
</form></div></div>
EOH;
$this->assertEquals($expected, form_close('</div></div>'));
Expand All @@ -739,7 +739,7 @@ public function testFormDatalist()
'foo1',
'bar1',
];
$expected = <<<EOH
$expected = <<<'EOH'
<input type="text" name="foo" value="bar" list="foo_list" />
<datalist id='foo_list'><option value='foo1'>
Expand Down
Loading

0 comments on commit 099fda5

Please sign in to comment.