Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6acb8c

Browse files
minor#52402 [Tests] Streamline (OskarStark)
This PR was squashed before being merged into the 7.1 branch.Discussion----------[Tests] Streamline| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | no| Deprecations? | no| Issues | --| License | MITFollows*#52157*#52365Commits-------33d71aa [Tests] Streamline
2 parentsc221681 +33d71aa commite6acb8c

File tree

114 files changed

+858
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+858
-582
lines changed

‎src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,11 @@ public function testNonInteractiveEncodePasswordUsesFirstUserClass()
277277

278278
publicfunctiontestThrowsExceptionOnNoConfiguredHashers()
279279
{
280+
$tester =newCommandTester(newUserPasswordHashCommand($this->getMockBuilder(PasswordHasherFactoryInterface::class)->getMock(), []));
281+
280282
$this->expectException(\RuntimeException::class);
281283
$this->expectExceptionMessage('There are no configured password hashers for the "security" extension.');
282284

283-
$tester =newCommandTester(newUserPasswordHashCommand($this->getMockBuilder(PasswordHasherFactoryInterface::class)->getMock(), []));
284285
$tester->execute([
285286
'password' =>'password',
286287
], ['interactive' =>false]);

‎src/Symfony/Component/PasswordHasher/Tests/Hasher/MessageDigestPasswordHasherTest.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ public function testHash()
3838

3939
publicfunctiontestHashAlgorithmDoesNotExist()
4040
{
41-
$this->expectException(\LogicException::class);
4241
$hasher =newMessageDigestPasswordHasher('foobar');
42+
43+
$this->expectException(\LogicException::class);
44+
4345
$hasher->hash('password','');
4446
}
4547

4648
publicfunctiontestHashLength()
4749
{
48-
$this->expectException(InvalidPasswordException::class);
4950
$hasher =newMessageDigestPasswordHasher();
5051

52+
$this->expectException(InvalidPasswordException::class);
53+
5154
$hasher->hash(str_repeat('a',5000),'salt');
5255
}
5356

‎src/Symfony/Component/PasswordHasher/Tests/Hasher/PasswordHasherFactoryTest.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,16 @@ public function testGetNullNamedHasherForHasherAware()
130130

131131
publicfunctiontestGetInvalidNamedHasherForHasherAware()
132132
{
133-
$this->expectException(\RuntimeException::class);
134133
$factory =newPasswordHasherFactory([
135134
HasherAwareUser::class =>newMessageDigestPasswordHasher('sha1'),
136135
'hasher_name' =>newMessageDigestPasswordHasher('sha256'),
137136
]);
138137

139138
$user =newHasherAwareUser();
140139
$user->hasherName ='invalid_hasher_name';
140+
141+
$this->expectException(\RuntimeException::class);
142+
141143
$factory->getPasswordHasher($user);
142144
}
143145

‎src/Symfony/Component/PasswordHasher/Tests/Hasher/Pbkdf2PasswordHasherTest.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ public function testHash()
3838

3939
publicfunctiontestHashAlgorithmDoesNotExist()
4040
{
41-
$this->expectException(\LogicException::class);
4241
$hasher =newPbkdf2PasswordHasher('foobar');
42+
43+
$this->expectException(\LogicException::class);
44+
4345
$hasher->hash('password','');
4446
}
4547

4648
publicfunctiontestHashLength()
4749
{
48-
$this->expectException(InvalidPasswordException::class);
4950
$hasher =newPbkdf2PasswordHasher('foobar');
5051

52+
$this->expectException(InvalidPasswordException::class);
53+
5154
$hasher->hash(str_repeat('a',5000),'salt');
5255
}
5356

‎src/Symfony/Component/PasswordHasher/Tests/Hasher/SodiumPasswordHasherTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function testNonArgonValidation()
5252
publicfunctiontestHashLength()
5353
{
5454
$this->expectException(InvalidPasswordException::class);
55-
$hasher =newSodiumPasswordHasher();
56-
$hasher->hash(str_repeat('a',4097));
55+
56+
(newSodiumPasswordHasher())->hash(str_repeat('a',4097));
5757
}
5858

5959
publicfunctiontestCheckPasswordLength()

‎src/Symfony/Component/Process/Tests/ProcessTest.php‎

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,13 @@ public function testSetInputWhileRunningThrowsAnException()
328328
/**
329329
* @dataProvider provideInvalidInputValues
330330
*/
331-
publicfunctiontestInvalidInput($value)
331+
publicfunctiontestInvalidInput(array|object$value)
332332
{
333+
$process =$this->getProcess('foo');
334+
333335
$this->expectException(InvalidArgumentException::class);
334336
$this->expectExceptionMessage('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources.');
335-
$process =$this->getProcess('foo');
337+
336338
$process->setInput($value);
337339
}
338340

@@ -347,7 +349,7 @@ public static function provideInvalidInputValues()
347349
/**
348350
* @dataProvider provideInputValues
349351
*/
350-
publicfunctiontestValidInput($expected,$value)
352+
publicfunctiontestValidInput(?string$expected,null|float|string$value)
351353
{
352354
$process =$this->getProcess('foo');
353355
$process->setInput($value);
@@ -593,8 +595,10 @@ public function testSuccessfulMustRunHasCorrectExitCode()
593595

594596
publicfunctiontestMustRunThrowsException()
595597
{
596-
$this->expectException(ProcessFailedException::class);
597598
$process =$this->getProcess('exit 1');
599+
600+
$this->expectException(ProcessFailedException::class);
601+
598602
$process->mustRun();
599603
}
600604

@@ -972,9 +976,11 @@ public function testExitCodeIsAvailableAfterSignal()
972976

973977
publicfunctiontestSignalProcessNotRunning()
974978
{
979+
$process =$this->getProcess('foo');
980+
975981
$this->expectException(LogicException::class);
976982
$this->expectExceptionMessage('Cannot send signal on a non running process.');
977-
$process =$this->getProcess('foo');
983+
978984
$process->signal(1);// SIGHUP
979985
}
980986

@@ -1062,20 +1068,24 @@ public function testDisableOutputDisablesTheOutput()
10621068

10631069
publicfunctiontestDisableOutputWhileRunningThrowsException()
10641070
{
1065-
$this->expectException(RuntimeException::class);
1066-
$this->expectExceptionMessage('Disabling output while the process is running is not possible.');
10671071
$p =$this->getProcessForCode('sleep(39);');
10681072
$p->start();
1073+
1074+
$this->expectException(RuntimeException::class);
1075+
$this->expectExceptionMessage('Disabling output while the process is running is not possible.');
1076+
10691077
$p->disableOutput();
10701078
}
10711079

10721080
publicfunctiontestEnableOutputWhileRunningThrowsException()
10731081
{
1074-
$this->expectException(RuntimeException::class);
1075-
$this->expectExceptionMessage('Enabling output while the process is running is not possible.');
10761082
$p =$this->getProcessForCode('sleep(40);');
10771083
$p->disableOutput();
10781084
$p->start();
1085+
1086+
$this->expectException(RuntimeException::class);
1087+
$this->expectExceptionMessage('Enabling output while the process is running is not possible.');
1088+
10791089
$p->enableOutput();
10801090
}
10811091

@@ -1091,19 +1101,23 @@ public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
10911101

10921102
publicfunctiontestDisableOutputWhileIdleTimeoutIsSet()
10931103
{
1094-
$this->expectException(LogicException::class);
1095-
$this->expectExceptionMessage('Output cannot be disabled while an idle timeout is set.');
10961104
$process =$this->getProcess('foo');
10971105
$process->setIdleTimeout(1);
1106+
1107+
$this->expectException(LogicException::class);
1108+
$this->expectExceptionMessage('Output cannot be disabled while an idle timeout is set.');
1109+
10981110
$process->disableOutput();
10991111
}
11001112

11011113
publicfunctiontestSetIdleTimeoutWhileOutputIsDisabled()
11021114
{
1103-
$this->expectException(LogicException::class);
1104-
$this->expectExceptionMessage('timeout cannot be set while the output is disabled.');
11051115
$process =$this->getProcess('foo');
11061116
$process->disableOutput();
1117+
1118+
$this->expectException(LogicException::class);
1119+
$this->expectExceptionMessage('timeout cannot be set while the output is disabled.');
1120+
11071121
$process->setIdleTimeout(1);
11081122
}
11091123

@@ -1119,11 +1133,13 @@ public function testSetNullIdleTimeoutWhileOutputIsDisabled()
11191133
*/
11201134
publicfunctiontestGetOutputWhileDisabled($fetchMethod)
11211135
{
1122-
$this->expectException(LogicException::class);
1123-
$this->expectExceptionMessage('Output has been disabled.');
11241136
$p =$this->getProcessForCode('sleep(41);');
11251137
$p->disableOutput();
11261138
$p->start();
1139+
1140+
$this->expectException(LogicException::class);
1141+
$this->expectExceptionMessage('Output has been disabled.');
1142+
11271143
$p->{$fetchMethod}();
11281144
}
11291145

@@ -1523,17 +1539,21 @@ public function testPreparedCommandWithQuoteInIt()
15231539

15241540
publicfunctiontestPreparedCommandWithMissingValue()
15251541
{
1542+
$p = Process::fromShellCommandline('echo "${:abc}"');
1543+
15261544
$this->expectException(InvalidArgumentException::class);
15271545
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"');
1528-
$p = Process::fromShellCommandline('echo "${:abc}"');
1546+
15291547
$p->run(null, ['bcd' =>'BCD']);
15301548
}
15311549

15321550
publicfunctiontestPreparedCommandWithNoValues()
15331551
{
1552+
$p = Process::fromShellCommandline('echo "${:abc}"');
1553+
15341554
$this->expectException(InvalidArgumentException::class);
15351555
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"');
1536-
$p = Process::fromShellCommandline('echo "${:abc}"');
1556+
15371557
$p->run(null, []);
15381558
}
15391559

‎src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTestCase.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ public function testGetValue($collection, $path, $value)
5353

5454
publicfunctiontestGetValueFailsIfNoSuchIndex()
5555
{
56-
$this->expectException(NoSuchIndexException::class);
5756
$this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
5857
->enableExceptionOnInvalidIndex()
5958
->getPropertyAccessor();
6059

6160
$object =static::getContainer(['firstName' =>'Bernhard']);
6261

62+
$this->expectException(NoSuchIndexException::class);
63+
6364
$this->propertyAccessor->getValue($object,'[lastName]');
6465
}
6566

‎src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTestCase.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections()
156156

157157
publicfunctiontestSetValueFailsIfNoAdderNorRemoverFound()
158158
{
159-
$this->expectException(NoSuchPropertyException::class);
160-
$this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTestCase_CarNoAdderAndRemover_[^"]*"./');
161159
$car =$this->createMock(__CLASS__.'_CarNoAdderAndRemover');
162160
$axesBefore =$this->getContainer([1 =>'second',3 =>'fourth']);
163161
$axesAfter =$this->getContainer([0 =>'first',1 =>'second',2 =>'third']);
@@ -166,6 +164,9 @@ public function testSetValueFailsIfNoAdderNorRemoverFound()
166164
->method('getAxes')
167165
->willReturn($axesBefore);
168166

167+
$this->expectException(NoSuchPropertyException::class);
168+
$this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTestCase_CarNoAdderAndRemover_[^"]*"./');
169+
169170
$this->propertyAccessor->setValue($car,'axes',$axesAfter);
170171
}
171172

@@ -195,9 +196,10 @@ public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists()
195196

196197
publicfunctiontestSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
197198
{
199+
$car =newPropertyAccessorCollectionTestCase_Car();
200+
198201
$this->expectException(NoSuchPropertyException::class);
199202
$this->expectExceptionMessageMatches('/The property "axes" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\PropertyAccessorCollectionTestCase_Car" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of\\\Traversable\./');
200-
$car =newPropertyAccessorCollectionTestCase_Car();
201203

202204
$this->propertyAccessor->setValue($car,'axes','Not an array or Traversable');
203205
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp