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

Remove tests that are now always skipped #945

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
182 changes: 0 additions & 182 deletions core-bundle/tests/EventListener/DoctrineSchemaListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
use Contao\CoreBundle\EventListener\DoctrineSchemaListener;
use Contao\CoreBundle\Tests\Doctrine\DoctrineTestCase;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use PHPUnit\Framework\MockObject\MockObject;

class DoctrineSchemaListenerTest extends DoctrineTestCase
{
Expand Down Expand Up @@ -53,184 +49,6 @@ public function testAppendsToAnExistingSchema(): void
$this->assertTrue($schema->getTable('tl_files')->hasColumn('path'));
}

public function testChangesTheIndexIfThereIsASubpart(): void
{
if (method_exists(AbstractPlatform::class, 'supportsColumnLengthIndexes')) {
$this->markTestSkipped('This test is only relevant for doctrine/dbal < 2.9');
}

$result = $this->createMock(ResultStatement::class);
$result
->method('fetch')
->willReturnOnConsecutiveCalls(
[
'Table' => 'tl_recipients',
'Non_unique' => '0',
'Key_name' => 'pid_email',
'Seq_in_index' => '1',
'Column_name' => 'pid',
'Collation' => 'A',
'Cardinality' => '2',
'Sub_part' => null,
'Packed' => null,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => '',
'Index_comment' => '',
],
[
'Table' => 'tl_recipients',
'Non_unique' => '0',
'Key_name' => 'pid_email',
'Seq_in_index' => '2',
'Column_name' => 'email',
'Collation' => 'A',
'Cardinality' => '2',
'Sub_part' => '191',
'Packed' => null,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => '',
'Index_comment' => '',
],
false
)
;

$connection = $this->createMock(Connection::class);
$connection
->method('getDatabasePlatform')
->willReturn(new MySqlPlatform())
;

$connection
->expects($this->once())
->method('executeQuery')
->with("SHOW INDEX FROM tl_recipients WHERE Key_name='path'")
->willReturn($result)
;

/** @var SchemaIndexDefinitionEventArgs&MockObject $event */
$event = $this
->getMockBuilder(SchemaIndexDefinitionEventArgs::class)
->disableOriginalConstructor()
->setMethods(['getConnection', 'getTable', 'getTableIndex', 'preventDefault', 'setIndex'])
->getMock()
;

$event
->method('getConnection')
->willReturn($connection)
;

$event
->method('getTable')
->willReturn('tl_recipients')
;

$event
->method('getTableIndex')
->willReturn($this->getIndexEventArg('path'))
;

$event
->expects($this->once())
->method('setIndex')
->with($this->callback(
function (Index $index) {
$this->assertSame(['pid', 'email(191)'], $index->getColumns());

return true;
}
))
;

$event
->expects($this->once())
->method('preventDefault')
;

$listener = new DoctrineSchemaListener($this->createMock(DcaSchemaProvider::class));
$listener->onSchemaIndexDefinition($event);
}

public function testDoesNotChangeTheIndexIfThereIsNoSubpart(): void
{
if (method_exists(AbstractPlatform::class, 'supportsColumnLengthIndexes')) {
$this->markTestSkipped('This test is only relevant for doctrine/dbal < 2.9');
}

$result = $this->createMock(ResultStatement::class);
$result
->method('fetch')
->willReturnOnConsecutiveCalls(
[
'Table' => 'tl_member',
'Non_unique' => '0',
'Key_name' => 'username',
'Seq_in_index' => '1',
'Column_name' => 'username',
'Collation' => 'A',
'Cardinality' => null,
'Sub_part' => null,
'Packed' => null,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => '',
'Index_comment' => '',
],
false
)
;

$connection = $this->createMock(Connection::class);
$connection
->method('getDatabasePlatform')
->willReturn(new MySqlPlatform())
;

$connection
->method('executeQuery')
->willReturn($result)
;

$event = $this->createMock(SchemaIndexDefinitionEventArgs::class);
$event
->method('getConnection')
->willReturn($connection)
;

$event
->method('getTable')
->willReturn('tl_member')
;

$event
->method('getTableIndex')
->willReturn($this->getIndexEventArg('username'))
;

$event
->expects($this->once())
->method('setIndex')
->with($this->callback(
function (Index $index) {
$this->assertSame(['username'], $index->getColumns());

return true;
}
))
;

$event
->expects($this->once())
->method('preventDefault')
;

$listener = new DoctrineSchemaListener($this->createMock(DcaSchemaProvider::class));
$listener->onSchemaIndexDefinition($event);
}

public function testDoesNotChangeTheIndexOfThePrimaryKeyColumn(): void
{
$connection = $this->createMock(Connection::class);
Expand Down
20 changes: 0 additions & 20 deletions core-bundle/tests/HttpKernel/ControllerResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Kernel;

class ControllerResolverTest extends TestCase
{
Expand Down Expand Up @@ -54,23 +53,4 @@ public function testForwardsTheControllerToTheDecoratedClass(): void
$resolver = new ControllerResolver($decorated, new FragmentRegistry());
$resolver->getController(new Request());
}

public function testForwardsArgumentsToDecoratedClass(): void
{
if (Kernel::MAJOR_VERSION > 3) {
$this->markTestSkipped('The getArguments() method has been removed in Symfony 4');

return;
}

$decorated = $this->createMock(ControllerResolverInterface::class);
$decorated
->expects($this->once())
->method('getArguments')
->willReturn([])
;

$resolver = new ControllerResolver($decorated, new FragmentRegistry());
$resolver->getArguments(new Request(), '');
}
}
35 changes: 0 additions & 35 deletions manager-bundle/tests/ContaoManager/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Contao\ManagerPlugin\Config\ContainerBuilder as PluginContainerBuilder;
use Contao\ManagerPlugin\PluginLoader;
use Contao\TestCase\ContaoTestCase;
use Contao\User;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
use FOS\HttpCacheBundle\FOSHttpCacheBundle;
Expand All @@ -44,7 +43,6 @@
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;

class PluginTest extends ContaoTestCase
{
Expand Down Expand Up @@ -346,37 +344,4 @@ public function testGetExtensionConfigDoctrine(): void

$this->assertSame($expect, $extensionConfig);
}

public function testFallsBackToBcryptIfAutoModeIsNotAvailable(): void
{
if (class_exists(NativePasswordEncoder::class)) {
$this->markTestSkipped('This test is only relevant for symfony/security <4.3');
}

$expect = [
[
'encoders' => [
User::class => [
'algorithm' => 'bcrypt',
],
],
],
];

$container = new PluginContainerBuilder($this->createMock(PluginLoader::class), []);

$extensionConfigs = [
[
'encoders' => [
User::class => [
'algorithm' => 'auto',
],
],
],
];

$extensionConfig = (new Plugin())->getExtensionConfig('security', $extensionConfigs, $container);

$this->assertSame($expect, $extensionConfig);
}
}