Skip to content

Commit

Permalink
Merge pull request #354 from tighten/drift/format-test-code
Browse files Browse the repository at this point in the history
Update test formatting
  • Loading branch information
driftingly authored Jan 6, 2024
2 parents 27ccf82 + 3cf8ef2 commit 8e70c8e
Show file tree
Hide file tree
Showing 39 changed files with 1,931 additions and 1,976 deletions.
2 changes: 1 addition & 1 deletion src/Linters/QualifiedNamesOnlyForClassName.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class QualifiedNamesOnlyForClassName extends BaseLinter

public function lint(Parser $parser)
{
if (preg_match('/\.blade\.php$/i', $this->filename)) {
if ($this->filename && preg_match('/\.blade\.php$/i', $this->filename)) {
return [];
}

Expand Down
262 changes: 131 additions & 131 deletions tests/Formatting/Formatters/ArrayParametersOverViewWithTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ class ArrayParametersOverViewWithTest extends TestCase
public function catches_view_with_method_usage_in_controller_methods()
{
$file = <<<'file'
<?php
<?php
namespace App;
namespace App;
class Controller
{
function index()
{
return view('test.view')->with('testing', '1212');
}
}
file;
class Controller
{
function index()
{
return view('test.view')->with('testing', '1212');
}
}
file;

$expected = <<<'file'
<?php
<?php
namespace App;
namespace App;
class Controller
{
function index()
{
return view('test.view', ['testing' => '1212']);
}
}
file;
class Controller
{
function index()
{
return view('test.view', ['testing' => '1212']);
}
}
file;

$formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file));

Expand All @@ -48,32 +48,32 @@ function index()
public function catches_view_with_chained_method_usage_in_controller_methods()
{
$file = <<<'file'
<?php
<?php
namespace App;
namespace App;
class Controller
{
function index()
{
return view('test.view')->with('first', 'yes')->with('second', 'no')->with('third', 'maybe');
}
}
file;
class Controller
{
function index()
{
return view('test.view')->with('first', 'yes')->with('second', 'no')->with('third', 'maybe');
}
}
file;

$expected = <<<'file'
<?php
<?php
namespace App;
namespace App;
class Controller
{
function index()
{
return view('test.view', ['first' => 'yes', 'second' => 'no', 'third' => 'maybe']);
}
}
file;
class Controller
{
function index()
{
return view('test.view', ['first' => 'yes', 'second' => 'no', 'third' => 'maybe']);
}
}
file;

$formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file));

Expand All @@ -84,35 +84,35 @@ function index()
public function catches_view_with_chained_new_lines_method_usage_in_controller_methods()
{
$file = <<<'file'
<?php
namespace App;
class Controller
{
function index()
{
return view('test.view')
->with('first', 'gold')
->with('second', 'silver')
->with('third', 'bronze');
}
}
file;
<?php
namespace App;
class Controller
{
function index()
{
return view('test.view')
->with('first', 'gold')
->with('second', 'silver')
->with('third', 'bronze');
}
}
file;

$expected = <<<'file'
<?php
<?php
namespace App;
namespace App;
class Controller
{
function index()
{
return view('test.view', ['first' => 'gold', 'second' => 'silver', 'third' => 'bronze']);
}
}
file;
class Controller
{
function index()
{
return view('test.view', ['first' => 'gold', 'second' => 'silver', 'third' => 'bronze']);
}
}
file;

$formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file));

Expand All @@ -122,21 +122,21 @@ function index()
/** @test */
public function catches_view_with_method_usage_in_routes()
{
$file = <<<file
<?php
$file = <<<'file'
<?php
\Route::get('test', function () {
return view('test')->with('test', 'test');
});
file;
\Route::get('test', function () {
return view('test')->with('test', 'test');
});
file;

$expected = <<<file
<?php
$expected = <<<'file'
<?php
\Route::get('test', function () {
return view('test', ['test' => 'test']);
});
file;
\Route::get('test', function () {
return view('test', ['test' => 'test']);
});
file;

$formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file));

Expand All @@ -147,62 +147,62 @@ public function catches_view_with_method_usage_in_routes()
public function catches_multiple_view_with_usage_in_controller_methods()
{
$file = <<<'file'
<?php
namespace App;
class Controller
{
function index()
{
return view('test.index')->with('first', 'yes');
}
function show()
{
return view('test.show', ['first' => 'yes']);
}
function create()
{
return view('test.create');
}
function edit()
{
return view('test.edit')->with('first', 'yes')->with('second', 'no');
}
}
file;
<?php
namespace App;
class Controller
{
function index()
{
return view('test.index')->with('first', 'yes');
}
function show()
{
return view('test.show', ['first' => 'yes']);
}
function create()
{
return view('test.create');
}
function edit()
{
return view('test.edit')->with('first', 'yes')->with('second', 'no');
}
}
file;

$expected = <<<'file'
<?php
namespace App;
class Controller
{
function index()
{
return view('test.index', ['first' => 'yes']);
}
function show()
{
return view('test.show', ['first' => 'yes']);
}
function create()
{
return view('test.create');
}
function edit()
{
return view('test.edit', ['first' => 'yes', 'second' => 'no']);
}
}
file;
<?php
namespace App;
class Controller
{
function index()
{
return view('test.index', ['first' => 'yes']);
}
function show()
{
return view('test.show', ['first' => 'yes']);
}
function create()
{
return view('test.create');
}
function edit()
{
return view('test.edit', ['first' => 'yes', 'second' => 'no']);
}
}
file;

$formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file));

Expand Down
Loading

0 comments on commit 8e70c8e

Please sign in to comment.