Skip to content

Commit 0597fd5

Browse files
committed
Split Laravel tests from GetValueFactoryTest to Laravel tests folder
1 parent b262118 commit 0597fd5

File tree

3 files changed

+69
-61
lines changed

3 files changed

+69
-61
lines changed

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
$config->skip([
3636
NewlineAfterStatementRector::class,
37-
StaticArrowFunctionRector::class => './tests/GetValueFactoryTest.php',
37+
StaticArrowFunctionRector::class => './tests/Laravel/GetValueFactoryLaravelTest.php',
3838
SimplifyBoolIdenticalTrueRector::class,
3939
]);
4040
};

tests/GetValueFactoryTest.php

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44

55
namespace Wrkflow\GetValueTests;
66

7-
use Illuminate\Foundation\Http\FormRequest;
8-
use Illuminate\Http\Request;
97
use PHPUnit\Framework\TestCase;
108
use SimpleXMLElement;
119
use Wrkflow\GetValue\GetValue;
1210
use Wrkflow\GetValue\GetValueFactory;
1311
use Wrkflow\GetValue\Strategies\NoTransformerStrategy;
1412
use Wrkflow\GetValueTests\Builders\CustomExceptionBuilder;
15-
use Wrkflow\GetValueTests\Mocks\ValidatorMock;
1613

1714
class GetValueFactoryTest extends TestCase
1815
{
@@ -57,63 +54,6 @@ public function testArray(): void
5754
$getValue->getRequiredString('no_value');
5855
}
5956

60-
public function testRequestAll(): void
61-
{
62-
if (class_exists(Request::class) === false) {
63-
$this->markTestSkipped('Laravel not installed.');
64-
}
65-
66-
$getValue = $this->factory->requestAll(new Request([
67-
'test' => 'This is a test',
68-
'not_validated' => 'Test',
69-
]));
70-
71-
$this->assertEquals('This is a test', $getValue->getRequiredString('test'));
72-
$this->assertEquals('Test', $getValue->getString('not_validated'));
73-
}
74-
75-
public function testRequestValidated(): void
76-
{
77-
if (class_exists(Request::class) === false) {
78-
$this->markTestSkipped('Laravel not installed.');
79-
}
80-
81-
$getValue = $this->factory->request($this->getFormRequest());
82-
83-
$this->assertEquals('This is a test', $getValue->getRequiredString('test'));
84-
$this->assertNull($getValue->getString('not_validated'));
85-
}
86-
87-
public function testRequestAllWithFormRequest(): void
88-
{
89-
if (class_exists(Request::class) === false) {
90-
$this->markTestSkipped('Laravel not installed.');
91-
}
92-
93-
$request = $this->getFormRequest();
94-
$getValue = $this->factory->requestAll($request);
95-
96-
$this->assertEquals('This is a test', $getValue->getRequiredString('test'));
97-
$this->assertEquals('Test', $getValue->getString('not_validated'));
98-
}
99-
100-
protected function getFormRequest(): FormRequest
101-
{
102-
$request = new FormRequest([
103-
'test' => 'This is a test',
104-
'not_validated' => 'Test',
105-
]);
106-
$validator = new ValidatorMock([
107-
'test' => 'This is a test',
108-
]);
109-
FormRequest::macro('validate', fn () => $validator->validate());
110-
$request->setValidator($validator);
111-
$request->validate([
112-
'test' => 'string',
113-
]);
114-
return $request;
115-
}
116-
11757
protected function createArray(): GetValue
11858
{
11959
return $this->factory->array([
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Wrkflow\GetValueTests\Laravel;
6+
7+
use Illuminate\Foundation\Http\FormRequest;
8+
use Illuminate\Http\Request;
9+
use PHPUnit\Framework\TestCase;
10+
use Wrkflow\GetValue\GetValueFactory;
11+
use Wrkflow\GetValueTests\Mocks\ValidatorMock;
12+
13+
class GetValueFactoryLaravelTest extends TestCase
14+
{
15+
private GetValueFactory $factory;
16+
17+
protected function setUp(): void
18+
{
19+
parent::setUp();
20+
21+
$this->factory = new GetValueFactory();
22+
}
23+
24+
public function testRequestAll(): void
25+
{
26+
$getValue = $this->factory->requestAll(new Request([
27+
'test' => 'This is a test',
28+
'not_validated' => 'Test',
29+
]));
30+
31+
$this->assertEquals('This is a test', $getValue->getRequiredString('test'));
32+
$this->assertEquals('Test', $getValue->getString('not_validated'));
33+
}
34+
35+
public function testRequestValidated(): void
36+
{
37+
$getValue = $this->factory->request($this->getFormRequest());
38+
39+
$this->assertEquals('This is a test', $getValue->getRequiredString('test'));
40+
$this->assertNull($getValue->getString('not_validated'));
41+
}
42+
43+
public function testRequestAllWithFormRequest(): void
44+
{
45+
$request = $this->getFormRequest();
46+
$getValue = $this->factory->requestAll($request);
47+
48+
$this->assertEquals('This is a test', $getValue->getRequiredString('test'));
49+
$this->assertEquals('Test', $getValue->getString('not_validated'));
50+
}
51+
52+
protected function getFormRequest(): FormRequest
53+
{
54+
$request = new FormRequest([
55+
'test' => 'This is a test',
56+
'not_validated' => 'Test',
57+
]);
58+
$validator = new ValidatorMock([
59+
'test' => 'This is a test',
60+
]);
61+
FormRequest::macro('validate', fn () => $validator->validate());
62+
$request->setValidator($validator);
63+
$request->validate([
64+
'test' => 'string',
65+
]);
66+
return $request;
67+
}
68+
}

0 commit comments

Comments
 (0)