Fixed tests

This commit is contained in:
Jan Böhmer 2025-09-21 21:35:13 +02:00
parent 0d49632b92
commit 1d52b7c464
4 changed files with 63 additions and 63 deletions

View file

@ -44,7 +44,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$client = static::createClient();
$this->loginAsUser($client, 'admin');
$client->request('GET', '/tools/bulk-info-provider-import/step1');
$client->request('GET', '/tools/bulk_info_provider_import/step1');
self::assertResponseRedirects();
}
@ -54,7 +54,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$client = static::createClient();
$this->loginAsUser($client, 'admin');
$client->request('GET', '/tools/bulk-info-provider-import/step1?ids=999999,888888');
$client->request('GET', '/tools/bulk_info_provider_import/step1?ids=999999,888888');
self::assertResponseRedirects();
}
@ -64,7 +64,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$client = static::createClient();
$this->loginAsUser($client, 'admin');
$client->request('GET', '/tools/bulk-info-provider-import/manage');
$client->request('GET', '/tools/bulk_info_provider_import/manage');
// Follow any redirects (like locale redirects)
if ($client->getResponse()->isRedirect()) {
@ -78,11 +78,11 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
{
$client = static::createClient();
$client->request('GET', '/tools/bulk-info-provider-import/step1?ids=1');
$client->request('GET', '/tools/bulk_info_provider_import/step1?ids=1');
self::assertResponseRedirects();
$this->loginAsUser($client, 'noread');
$client->request('GET', '/tools/bulk-info-provider-import/step1?ids=1');
$client->request('GET', '/tools/bulk_info_provider_import/step1?ids=1');
// Follow redirects if any, then check for 403 or final response
if ($client->getResponse()->isRedirect()) {
@ -100,11 +100,11 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
{
$client = static::createClient();
$client->request('GET', '/tools/bulk-info-provider-import/manage');
$client->request('GET', '/tools/bulk_info_provider_import/manage');
self::assertResponseRedirects();
$this->loginAsUser($client, 'noread');
$client->request('GET', '/tools/bulk-info-provider-import/manage');
$client->request('GET', '/tools/bulk_info_provider_import/manage');
// Follow redirects if any, then check for 403 or final response
if ($client->getResponse()->isRedirect()) {
@ -164,7 +164,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->flush();
// Test that step2 renders correctly with the search results
$client->request('GET', '/tools/bulk-info-provider-import/step2/' . $job->getId());
$client->request('GET', '/tools/bulk_info_provider_import/step2/' . $job->getId());
// Follow any redirects (like locale redirects)
if ($client->getResponse()->isRedirect()) {
@ -201,7 +201,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$this->markTestSkipped('Test part with ID 1 not found in fixtures');
}
$client->request('GET', '/tools/bulk-info-provider-import/step1?ids=' . $part->getId());
$client->request('GET', '/tools/bulk_info_provider_import/step1?ids=' . $part->getId());
if ($client->getResponse()->isRedirect()) {
$client->followRedirect();
@ -242,7 +242,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('DELETE', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/delete');
$client->request('DELETE', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/delete');
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
$response = json_decode($client->getResponse()->getContent(), true);
@ -254,7 +254,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$client = static::createClient();
$this->loginAsUser($client, 'admin');
$client->request('DELETE', '/en/tools/bulk-info-provider-import/job/999999/delete');
$client->request('DELETE', '/en/tools/bulk_info_provider_import/job/999999/delete');
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
$response = json_decode($client->getResponse()->getContent(), true);
@ -289,7 +289,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('DELETE', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/delete');
$client->request('DELETE', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/delete');
$this->assertResponseStatusCodeSame(Response::HTTP_BAD_REQUEST);
$response = json_decode($client->getResponse()->getContent(), true);
@ -328,7 +328,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/stop');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/stop');
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
$response = json_decode($client->getResponse()->getContent(), true);
@ -344,7 +344,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$client = static::createClient();
$this->loginAsUser($client, 'admin');
$client->request('POST', '/en/tools/bulk-info-provider-import/job/999999/stop');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/999999/stop');
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
$response = json_decode($client->getResponse()->getContent(), true);
@ -378,7 +378,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/part/1/mark-completed');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/part/1/mark-completed');
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
$response = json_decode($client->getResponse()->getContent(), true);
@ -418,7 +418,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/part/1/mark-skipped', [
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/part/1/mark-skipped', [
'reason' => 'Test skip reason'
]);
@ -459,7 +459,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/part/1/mark-pending');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/part/1/mark-pending');
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
$response = json_decode($client->getResponse()->getContent(), true);
@ -475,7 +475,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$client = static::createClient();
$this->loginAsUser($client, 'admin');
$client->request('GET', '/tools/bulk-info-provider-import/step2/999999');
$client->request('GET', '/tools/bulk_info_provider_import/step2/999999');
$this->assertResponseRedirects();
}
@ -511,7 +511,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
// Try to access as readonly user
$this->loginAsUser($client, 'noread');
$client->request('GET', '/tools/bulk-info-provider-import/step2/' . $job->getId());
$client->request('GET', '/tools/bulk_info_provider_import/step2/' . $job->getId());
$this->assertResponseRedirects();
@ -550,7 +550,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->flush();
// Try to delete as admin (should fail due to ownership)
$client->request('DELETE', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/delete');
$client->request('DELETE', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/delete');
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
@ -601,7 +601,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$this->markTestSkipped('Test part with ID 1 not found in fixtures');
}
$client->request('GET', '/tools/bulk-info-provider-import/step1?ids=' . $part->getId());
$client->request('GET', '/tools/bulk_info_provider_import/step1?ids=' . $part->getId());
if ($client->getResponse()->isRedirect()) {
$client->followRedirect();
@ -624,7 +624,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$this->markTestSkipped('Test part with ID 1 not found in fixtures');
}
$client->request('GET', '/tools/bulk-info-provider-import/step1?ids=' . $part->getId());
$client->request('GET', '/tools/bulk_info_provider_import/step1?ids=' . $part->getId());
if ($client->getResponse()->isRedirect()) {
$client->followRedirect();
@ -694,7 +694,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('GET', '/tools/bulk-info-provider-import/manage');
$client->request('GET', '/tools/bulk_info_provider_import/manage');
if ($client->getResponse()->isRedirect()) {
$client->followRedirect();
@ -828,18 +828,18 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/stop');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/stop');
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/part/1/mark-completed');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/part/1/mark-completed');
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/part/1/mark-skipped', [
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/part/1/mark-skipped', [
'reason' => 'Test reason'
]);
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/part/1/mark-pending');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/part/1/mark-pending');
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
// Find job from database to avoid detached entity errors
@ -878,7 +878,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase
$entityManager->persist($job);
$entityManager->flush();
$client->request('POST', '/en/tools/bulk-info-provider-import/job/' . $job->getId() . '/stop');
$client->request('POST', '/en/tools/bulk_info_provider_import/job/' . $job->getId() . '/stop');
$this->assertResponseStatusCodeSame(Response::HTTP_BAD_REQUEST);
$response = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('error', $response);

View file

@ -46,17 +46,17 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testConstructor(): void
{
$this->assertEquals([], $this->constraint->getValues());
$this->assertNull($this->constraint->getOperator());
$this->assertEquals([], $this->constraint->getValue());
$this->assertEmpty($this->constraint->getOperator());
$this->assertFalse($this->constraint->isEnabled());
}
public function testGetAndSetValues(): void
{
$values = ['pending', 'in_progress'];
$this->constraint->setValues($values);
$this->constraint->setValue($values);
$this->assertEquals($values, $this->constraint->getValues());
$this->assertEquals($values, $this->constraint->getValue());
}
public function testGetAndSetOperator(): void
@ -76,14 +76,14 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testIsEnabledWithNullOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->assertFalse($this->constraint->isEnabled());
}
public function testIsEnabledWithValuesAndOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('ANY');
$this->assertTrue($this->constraint->isEnabled());
@ -101,7 +101,7 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testApplyWithNullOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->queryBuilder->expects($this->never())
->method('andWhere');
@ -111,7 +111,7 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testApplyWithAnyOperator(): void
{
$this->constraint->setValues(['pending', 'in_progress']);
$this->constraint->setValue(['pending', 'in_progress']);
$this->constraint->setOperator('ANY');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -138,7 +138,7 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testApplyWithNoneOperator(): void
{
$this->constraint->setValues(['completed']);
$this->constraint->setValue(['completed']);
$this->constraint->setOperator('NONE');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -165,7 +165,7 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testApplyWithUnsupportedOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('UNKNOWN');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -187,7 +187,7 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testSubqueryStructure(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('ANY');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -231,17 +231,17 @@ class BulkImportJobStatusConstraintTest extends TestCase
public function testValuesAndOperatorMutation(): void
{
// Test that values and operator can be changed after creation
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('ANY');
$this->assertTrue($this->constraint->isEnabled());
$this->constraint->setValues([]);
$this->constraint->setValue([]);
$this->assertFalse($this->constraint->isEnabled());
$this->constraint->setValues(['completed']);
$this->constraint->setValue(['completed']);
$this->assertTrue($this->constraint->isEnabled());
$this->constraint->setOperator(null);
$this->constraint->setOperator('');
$this->assertFalse($this->constraint->isEnabled());
$this->constraint->setOperator('NONE');

View file

@ -46,17 +46,17 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testConstructor(): void
{
$this->assertEquals([], $this->constraint->getValues());
$this->assertNull($this->constraint->getOperator());
$this->assertEquals([], $this->constraint->getValue());
$this->assertEmpty($this->constraint->getOperator());
$this->assertFalse($this->constraint->isEnabled());
}
public function testGetAndSetValues(): void
{
$values = ['pending', 'completed', 'skipped'];
$this->constraint->setValues($values);
$this->constraint->setValue($values);
$this->assertEquals($values, $this->constraint->getValues());
$this->assertEquals($values, $this->constraint->getValue());
}
public function testGetAndSetOperator(): void
@ -76,14 +76,14 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testIsEnabledWithNullOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->assertFalse($this->constraint->isEnabled());
}
public function testIsEnabledWithValuesAndOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('ANY');
$this->assertTrue($this->constraint->isEnabled());
@ -101,7 +101,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testApplyWithNullOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->queryBuilder->expects($this->never())
->method('andWhere');
@ -111,7 +111,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testApplyWithAnyOperator(): void
{
$this->constraint->setValues(['pending', 'completed']);
$this->constraint->setValue(['pending', 'completed']);
$this->constraint->setOperator('ANY');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -137,7 +137,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testApplyWithNoneOperator(): void
{
$this->constraint->setValues(['failed']);
$this->constraint->setValue(['failed']);
$this->constraint->setOperator('NONE');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -163,7 +163,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testApplyWithUnsupportedOperator(): void
{
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('UNKNOWN');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -184,7 +184,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testSubqueryStructure(): void
{
$this->constraint->setValues(['completed', 'skipped']);
$this->constraint->setValue(['completed', 'skipped']);
$this->constraint->setOperator('ANY');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -223,17 +223,17 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testValuesAndOperatorMutation(): void
{
// Test that values and operator can be changed after creation
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('ANY');
$this->assertTrue($this->constraint->isEnabled());
$this->constraint->setValues([]);
$this->constraint->setValue([]);
$this->assertFalse($this->constraint->isEnabled());
$this->constraint->setValues(['completed', 'skipped']);
$this->constraint->setValue(['completed', 'skipped']);
$this->assertTrue($this->constraint->isEnabled());
$this->constraint->setOperator(null);
$this->constraint->setOperator("");
$this->assertFalse($this->constraint->isEnabled());
$this->constraint->setOperator('NONE');
@ -244,7 +244,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
{
// This constraint should work differently from BulkImportJobStatusConstraint
// It queries the part status directly, not the job status
$this->constraint->setValues(['pending']);
$this->constraint->setValue(['pending']);
$this->constraint->setOperator('ANY');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -275,7 +275,7 @@ class BulkImportPartStatusConstraintTest extends TestCase
public function testMultipleStatusValues(): void
{
$statusValues = ['pending', 'completed', 'skipped', 'failed'];
$this->constraint->setValues($statusValues);
$this->constraint->setValue($statusValues);
$this->constraint->setOperator('ANY');
$subQueryBuilder = $this->createMock(QueryBuilder::class);
@ -294,6 +294,6 @@ class BulkImportPartStatusConstraintTest extends TestCase
$this->constraint->apply($this->queryBuilder);
$this->assertEquals($statusValues, $this->constraint->getValues());
$this->assertEquals($statusValues, $this->constraint->getValue());
}
}

View file

@ -51,14 +51,14 @@ class ElementTypeNameGeneratorTest extends WebTestCase
//We only test in english
$this->assertSame('Part', $this->service->getLocalizedTypeLabel(new Part()));
$this->assertSame('Category', $this->service->getLocalizedTypeLabel(new Category()));
$this->assertSame('Bulk Info Provider Import', $this->service->getLocalizedTypeLabel(new BulkInfoProviderImportJob()));
$this->assertSame('Bulk info provider import', $this->service->getLocalizedTypeLabel(new BulkInfoProviderImportJob()));
//Test inheritance
$this->assertSame('Attachment', $this->service->getLocalizedTypeLabel(new PartAttachment()));
//Test for class name
$this->assertSame('Part', $this->service->getLocalizedTypeLabel(Part::class));
$this->assertSame('Bulk Info Provider Import', $this->service->getLocalizedTypeLabel(BulkInfoProviderImportJob::class));
$this->assertSame('Bulk info provider import', $this->service->getLocalizedTypeLabel(BulkInfoProviderImportJob::class));
//Test exception for unknpwn type
$this->expectException(EntityNotSupportedException::class);