Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Don't expect class when its module isn't installed #11488

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tests/php/Forms/FormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Forms\Tests;

use Composer\InstalledVersions;
use LogicException;
use ReflectionClass;
use SilverStripe\Core\ClassInfo;
Expand Down Expand Up @@ -932,9 +933,6 @@ public function testFieldValidatorConfig(): void
SelectionGroup_Item::class => [
CompositeFieldValidator::class,
],
SegmentField::class => [
StringFieldValidator::class,
],
SingleLookupField::class => [],
Tab::class => [
CompositeFieldValidator::class,
Expand Down Expand Up @@ -967,6 +965,11 @@ public function testFieldValidatorConfig(): void
StringFieldValidator::class,
],
];
if (InstalledVersions::isInstalled('silverstripe/segment-field')) {
$expectedFieldValidators[SegmentField::class] = [
StringFieldValidator::class,
];
}
$count = 0;
foreach ($this->getFormFieldClasses() as $class) {
if (!array_key_exists($class, $expectedFieldValidators)) {
Expand All @@ -983,7 +986,7 @@ public function testFieldValidatorConfig(): void
}
// Assert that we have tested all classes e.g. namespace wasn't changed, no new classes were added
// that haven't been tested
$this->assertSame(58, $count);
$this->assertSame(count($expectedFieldValidators), $count);
}

private function instantiateFormField(string $class): FormField
Expand Down
Loading