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

[PhpUnitBridge] Fix deprecation assertInternalType #32846

Merged
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
Expand Up @@ -1466,7 +1466,7 @@ public function testSetDataEmptyArraySubmitNullMultiple()
]);
$form->setData($emptyArray);
$form->submit(null);
$this->assertInternalType('array', $form->getData());
$this->assertIsArray($form->getData());
$this->assertEquals([], $form->getData());
$this->assertEquals([], $form->getNormData());
$this->assertSame([], $form->getViewData(), 'View data is always an array');
Expand All @@ -1484,7 +1484,7 @@ public function testSetDataNonEmptyArraySubmitNullMultiple()
$existing = [0 => $entity1];
$form->setData($existing);
$form->submit(null);
$this->assertInternalType('array', $form->getData());
$this->assertIsArray($form->getData());
$this->assertEquals([], $form->getData());
$this->assertEquals([], $form->getNormData());
$this->assertSame([], $form->getViewData(), 'View data is always an array');
Expand Down
110 changes: 110 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php
Expand Up @@ -79,4 +79,114 @@ private function doTearDown()
{
parent::tearDown();
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsArray($actual, $message = '')
{
static::assertInternalType('array', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsBool($actual, $message = '')
{
static::assertInternalType('bool', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsFloat($actual, $message = '')
{
static::assertInternalType('float', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsInt($actual, $message = '')
{
static::assertInternalType('int', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsNumeric($actual, $message = '')
{
static::assertInternalType('numeric', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsObject($actual, $message = '')
{
static::assertInternalType('object', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsResource($actual, $message = '')
{
static::assertInternalType('resource', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsString($actual, $message = '')
{
static::assertInternalType('string', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsScalar($actual, $message = '')
{
static::assertInternalType('scalar', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsCallable($actual, $message = '')
{
static::assertInternalType('callable', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertIsIterable($actual, $message = '')
{
static::assertInternalType('iterable', $actual, $message);
}
}
Expand Up @@ -50,7 +50,7 @@ public function testWarmUp()

$values = $fallbackPool->getValues();

$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(2, $values);
$this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person', $values);
$this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author', $values);
Expand All @@ -74,7 +74,7 @@ public function testWarmUpWithoutLoader()

$values = $fallbackPool->getValues();

$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(0, $values);
}
}
Expand Up @@ -46,7 +46,7 @@ public function testWarmUp()

$values = $fallbackPool->getValues();

$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(2, $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person', $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author', $values);
Expand Down Expand Up @@ -77,7 +77,7 @@ public function testWarmUpWithAnnotations()

$values = $fallbackPool->getValues();

$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(2, $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.SubCategory', $values);
Expand All @@ -99,7 +99,7 @@ public function testWarmUpWithoutLoader()

$values = $fallbackPool->getValues();

$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(0, $values);
}
}
Expand Up @@ -30,7 +30,7 @@ public function testProfilerIsDisabled($insulate)
$client->enableProfiler();
$this->assertFalse($client->getProfile());
$client->request('GET', '/profiler');
$this->assertInternalType('object', $client->getProfile());
$this->assertIsObject($client->getProfile());

$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
Expand Down
Expand Up @@ -12,11 +12,14 @@
namespace Symfony\Component\Config\Tests\Definition\Builder;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;

class TreeBuilderTest extends TestCase
{
use ForwardCompatTestTrait;

public function testUsingACustomNodeBuilder()
{
$builder = new TreeBuilder();
Expand Down Expand Up @@ -128,7 +131,7 @@ public function testDefinitionExampleGetsTransferredToNode()
$tree = $builder->buildTree();
$children = $tree->getChildren();

$this->assertInternalType('array', $tree->getExample());
$this->assertIsArray($tree->getExample());
$this->assertEquals('example', $children['child']->getExample());
}
}
Expand Up @@ -16,6 +16,7 @@

use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface as PsrContainerInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\ComposerResource;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\Config\Resource\FileResource;
Expand Down Expand Up @@ -45,6 +46,8 @@

class ContainerBuilderTest extends TestCase
{
use ForwardCompatTestTrait;

public function testDefaultRegisteredDefinitions()
{
$builder = new ContainerBuilder();
Expand Down Expand Up @@ -168,7 +171,7 @@ public function testGetCreatesServiceBasedOnDefinition()
$builder = new ContainerBuilder();
$builder->register('foo', 'stdClass');

$this->assertInternalType('object', $builder->get('foo'), '->get() returns the service definition associated with the id');
$this->assertIsObject($builder->get('foo'), '->get() returns the service definition associated with the id');
}

public function testGetReturnsRegisteredService()
Expand Down Expand Up @@ -662,7 +665,7 @@ public function testResolveEnvValuesWithArray()
$container->resolveEnvPlaceholders('%dummy%', true);
$container->resolveEnvPlaceholders('%dummy2%', true);

$this->assertInternalType('array', $container->resolveEnvPlaceholders('%dummy2%', true));
$this->assertIsArray($container->resolveEnvPlaceholders('%dummy2%', true));

foreach ($dummyArray as $key => $value) {
$this->assertArrayHasKey($key, $container->resolveEnvPlaceholders('%dummy2%', true));
Expand Down
Expand Up @@ -599,7 +599,7 @@ public function testAnonymousServices()

// Anonymous service in a callable
$factory = $definition->getFactory();
$this->assertInternalType('array', $factory);
$this->assertIsArray($factory);
$this->assertInstanceOf(Reference::class, $factory[0]);
$this->assertTrue($container->has((string) $factory[0]));
$this->assertRegExp('/^\d+_Quz~[._A-Za-z0-9]{7}$/', (string) $factory[0]);
Expand Down
Expand Up @@ -12,10 +12,13 @@
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;

class EnvPlaceholderParameterBagTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
*/
Expand All @@ -42,7 +45,7 @@ public function testMergeWillNotDuplicateIdenticalParameters()
$placeholder = array_values($placeholderForVariable)[0];

$this->assertCount(1, $placeholderForVariable);
$this->assertInternalType('string', $placeholder);
$this->assertIsString($placeholder);
$this->assertContains($envVariableName, $placeholder);
}

Expand All @@ -65,7 +68,7 @@ public function testMergeWhereFirstBagIsEmptyWillWork()
$placeholder = array_values($placeholderForVariable)[0];

$this->assertCount(1, $placeholderForVariable);
$this->assertInternalType('string', $placeholder);
$this->assertIsString($placeholder);
$this->assertContains($envVariableName, $placeholder);
}

Expand Down
7 changes: 5 additions & 2 deletions src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
Expand Up @@ -12,10 +12,13 @@
namespace Symfony\Component\DomCrawler\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DomCrawler\Crawler;

class CrawlerTest extends TestCase
{
use ForwardCompatTestTrait;

public function testConstructor()
{
$crawler = new Crawler();
Expand Down Expand Up @@ -843,7 +846,7 @@ public function testChaining()
public function testLinks()
{
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo');
$this->assertInternalType('array', $crawler->links(), '->links() returns an array');
$this->assertIsArray($crawler->links(), '->links() returns an array');

$this->assertCount(4, $crawler->links(), '->links() returns an array');
$links = $crawler->links();
Expand All @@ -855,7 +858,7 @@ public function testLinks()
public function testImages()
{
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar');
$this->assertInternalType('array', $crawler->images(), '->images() returns an array');
$this->assertIsArray($crawler->images(), '->images() returns an array');

$this->assertCount(4, $crawler->images(), '->images() returns an array');
$images = $crawler->images();
Expand Down
Expand Up @@ -11,10 +11,13 @@

namespace Symfony\Component\DomCrawler\Tests\Field;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DomCrawler\Field\FileFormField;

class FileFormFieldTest extends FormFieldTestCase
{
use ForwardCompatTestTrait;

public function testInitialize()
{
$node = $this->createNode('input', '', ['type' => 'file']);
Expand Down Expand Up @@ -55,7 +58,7 @@ public function testSetValue($method)

$this->assertEquals(basename(__FILE__), $value['name'], "->$method() sets the name of the file field");
$this->assertEquals('', $value['type'], "->$method() sets the type of the file field");
$this->assertInternalType('string', $value['tmp_name'], "->$method() sets the tmp_name of the file field");
$this->assertIsString($value['tmp_name'], "->$method() sets the tmp_name of the file field");
$this->assertFileExists($value['tmp_name'], "->$method() creates a copy of the file at the tmp_name path");
$this->assertEquals(0, $value['error'], "->$method() sets the error of the file field");
$this->assertEquals(filesize(__FILE__), $value['size'], "->$method() sets the size of the file field");
Expand Down
Expand Up @@ -39,7 +39,7 @@ public function testLoadTypeExtensions()
{
$typeExtensions = $this->extension->getTypeExtensions('Symfony\Component\Form\Extension\Core\Type\FormType');

$this->assertInternalType('array', $typeExtensions);
$this->assertIsArray($typeExtensions);
$this->assertCount(1, $typeExtensions);
$this->assertInstanceOf('Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension', array_shift($typeExtensions));
}
Expand Down
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Form\Tests\Extension\Validator\Type;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Test\FormInterface;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\Validator\Constraints\GroupSequence;
Expand All @@ -20,6 +21,8 @@
*/
abstract class BaseValidatorExtensionTest extends TypeTestCase
{
use ForwardCompatTestTrait;

public function testValidationGroupNullByDefault()
{
$form = $this->createForm();
Expand Down Expand Up @@ -60,7 +63,7 @@ public function testValidationGroupsCanBeSetToCallback()
'validation_groups' => [$this, 'testValidationGroupsCanBeSetToCallback'],
]);

$this->assertInternalType('callable', $form->getConfig()->getOption('validation_groups'));
$this->assertIsCallable($form->getConfig()->getOption('validation_groups'));
}

public function testValidationGroupsCanBeSetToClosure()
Expand All @@ -69,7 +72,7 @@ public function testValidationGroupsCanBeSetToClosure()
'validation_groups' => function (FormInterface $form) { },
]);

$this->assertInternalType('callable', $form->getConfig()->getOption('validation_groups'));
$this->assertIsCallable($form->getConfig()->getOption('validation_groups'));
}

public function testValidationGroupsCanBeSetToGroupSequence()
Expand Down