Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -19,6 +19,7 @@ use App\Event\CustomerMetaDefinitionEvent;
use App\Event\CustomerUpdatePostEvent;
use App\Event\CustomerUpdatePreEvent;
use App\Repository\CustomerRepository;
use App\Tests\Mocks\SystemConfigurationFactory;
use App\Validator\ValidationFailedException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -43,6 +44,9 @@ class CustomerServiceTest extends TestCase
if ($dispatcher === null) {
$dispatcher = $this->createMock(EventDispatcherInterface::class);
$dispatcher->method('dispatch')->willReturnCallback(function ($event) {
return $event;
});
}
if ($validator === null) {
@@ -51,15 +55,18 @@ class CustomerServiceTest extends TestCase
}
if ($configuration === null) {
$configuration = $this->createMock(SystemConfiguration::class);
$configuration->method('getCustomerDefaultTimezone')->willReturn('Europe/Vienna');
$configuration->method('getCustomerDefaultCountry')->willReturn('IN');
$configuration->method('getCustomerDefaultCurrency')->willReturn('RUB');
$configuration = SystemConfigurationFactory::createStub([
'defaults' => [
'customer' => [
'timezone' => 'Europe/Vienna',
'country' => 'IN',
'currency' => 'RUB',
]
]
]);
}
$service = new CustomerService($repository, $configuration, $validator, $dispatcher);
return $service;
return new CustomerService($repository, $configuration, $validator, $dispatcher);
}
public function testCannotSavePersistedCustomerAsNew()
@@ -88,7 +95,7 @@ class CustomerServiceTest extends TestCase
$this->expectException(ValidationFailedException::class);
$this->expectExceptionMessage('Validation Failed');
$sut->saveNewCustomer(new Customer());
$sut->saveNewCustomer(new Customer('foo'));
}
public function testUpdateDispatchesEvents()
@@ -105,6 +112,8 @@ class CustomerServiceTest extends TestCase
} else {
$this->fail('Invalid event received');
}
return $event;
});
$sut = $this->getSut($dispatcher);
@@ -123,11 +132,13 @@ class CustomerServiceTest extends TestCase
} else {
$this->fail('Invalid event received');
}
return $event;
});
$sut = $this->getSut($dispatcher);
$customer = $sut->createNewCustomer();
$customer = $sut->createNewCustomer('');
self::assertInstanceOf(Customer::class, $customer);
self::assertEquals('Europe/Vienna', $customer->getTimezone());
@@ -146,11 +157,13 @@ class CustomerServiceTest extends TestCase
} else {
$this->fail('Invalid event received');
}
return $event;
});
$sut = $this->getSut($dispatcher);
$Customer = new Customer();
$Customer = new Customer('foo');
$sut->saveNewCustomer($Customer);
}
}