Skip to content

Commit

Permalink
Fix deprecation on 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Aug 6, 2019
1 parent 36466a3 commit 914a800
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -30,6 +30,9 @@ matrix:
env: deps=high
- php: 7.3
env: deps=low
- php: 7.4snapshot
allow_failures:
- php: 7.4snapshot
fast_finish: true

cache:
Expand Down
Expand Up @@ -120,7 +120,7 @@ public function testGetMetadata()
CacheItem::METADATA_EXPIRY => 9.5 + time(),
CacheItem::METADATA_CTIME => 1000,
];
$this->assertEquals($expected, $item->getMetadata(), 'Item metadata should embed expiry and ctime.', .6);
$this->assertEqualsWithDelta($expected, $item->getMetadata(), .6, 'Item metadata should embed expiry and ctime.');
}

public function testDefaultLifeTime()
Expand Down
Expand Up @@ -18,22 +18,22 @@

class NodeDefinitionTest extends TestCase
{
public function testDefaultPathSeparatorIsDot()
{
$node = $this->getMockForAbstractClass(NodeDefinition::class, ['foo']);

$this->assertAttributeSame('.', 'pathSeparator', $node);
}

public function testSetPathSeparatorChangesChildren()
{
$node = new ArrayNodeDefinition('foo');
$scalar = new ScalarNodeDefinition('bar');
$node->append($scalar);

$node->setPathSeparator('/');

$this->assertAttributeSame('/', 'pathSeparator', $node);
$this->assertAttributeSame('/', 'pathSeparator', $scalar);
$parentNode = new ArrayNodeDefinition('name');
$childNode = $this->createMock(NodeDefinition::class);

$childNode
->expects($this->once())
->method('setPathSeparator')
->with('/');
$childNode
->expects($this->once())
->method('setParent')
->with($parentNode)
->willReturn($childNode);
$parentNode->append($childNode);

$parentNode->setPathSeparator('/');
}
}
Expand Up @@ -235,7 +235,7 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
if ($parameter->isDefaultValueAvailable()) {
$value = $parameter->getDefaultValue();
} elseif (!$parameter->allowsNull()) {
throw new AutowiringFailedException($this->currentId, $failureMessage);
throw new AutowiringFailedException($this->currentId, $failureMessage());
}
}

Expand Down
Expand Up @@ -51,11 +51,11 @@ public function testChoiceTranslationLocaleOption()
->createView()->vars['choices'];

// Don't check objects for identity
$this->assertContains(new ChoiceView('DE', 'DE', 'Німеччина'), $choices, '', false, false);
$this->assertContains(new ChoiceView('GB', 'GB', 'Велика Британія'), $choices, '', false, false);
$this->assertContains(new ChoiceView('US', 'US', 'Сполучені Штати'), $choices, '', false, false);
$this->assertContains(new ChoiceView('FR', 'FR', 'Франція'), $choices, '', false, false);
$this->assertContains(new ChoiceView('MY', 'MY', 'Малайзія'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('DE', 'DE', 'Німеччина'), $choices);
$this->assertContainsEquals(new ChoiceView('GB', 'GB', 'Велика Британія'), $choices);
$this->assertContainsEquals(new ChoiceView('US', 'US', 'Сполучені Штати'), $choices);
$this->assertContainsEquals(new ChoiceView('FR', 'FR', 'Франція'), $choices);
$this->assertContainsEquals(new ChoiceView('MY', 'MY', 'Малайзія'), $choices);
}

public function testUnknownCountryIsNotIncluded()
Expand Down
Expand Up @@ -48,9 +48,9 @@ public function testChoiceTranslationLocaleOption()
->createView()->vars['choices'];

// Don't check objects for identity
$this->assertContains(new ChoiceView('EUR', 'EUR', 'євро'), $choices, '', false, false);
$this->assertContains(new ChoiceView('USD', 'USD', 'долар США'), $choices, '', false, false);
$this->assertContains(new ChoiceView('SIT', 'SIT', 'словенський толар'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'євро'), $choices);
$this->assertContainsEquals(new ChoiceView('USD', 'USD', 'долар США'), $choices);
$this->assertContainsEquals(new ChoiceView('SIT', 'SIT', 'словенський толар'), $choices);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down
Expand Up @@ -50,10 +50,10 @@ public function testChoiceTranslationLocaleOption()
->createView()->vars['choices'];

// Don't check objects for identity
$this->assertContains(new ChoiceView('en', 'en', 'англійська'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_US', 'en_US', 'англійська (США)'), $choices, '', false, false);
$this->assertContains(new ChoiceView('fr', 'fr', 'французька'), $choices, '', false, false);
$this->assertContains(new ChoiceView('my', 'my', 'бірманська'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('en', 'en', 'англійська'), $choices);
$this->assertContainsEquals(new ChoiceView('en_US', 'en_US', 'англійська (США)'), $choices);
$this->assertContainsEquals(new ChoiceView('fr', 'fr', 'французька'), $choices);
$this->assertContainsEquals(new ChoiceView('my', 'my', 'бірманська'), $choices);
}

public function testMultipleLanguagesIsNotIncluded()
Expand Down
Expand Up @@ -48,9 +48,9 @@ public function testChoiceTranslationLocaleOption()
->createView()->vars['choices'];

// Don't check objects for identity
$this->assertContains(new ChoiceView('en', 'en', 'англійська'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_GB', 'en_GB', 'англійська (Велика Британія)'), $choices, '', false, false);
$this->assertContains(new ChoiceView('zh_Hant_MO', 'zh_Hant_MO', 'китайська (традиційна, Макао, О.А.Р Китаю)'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('en', 'en', 'англійська'), $choices);
$this->assertContainsEquals(new ChoiceView('en_GB', 'en_GB', 'англійська (Велика Британія)'), $choices);
$this->assertContainsEquals(new ChoiceView('zh_Hant_MO', 'zh_Hant_MO', 'китайська (традиційна, Макао, О.А.Р Китаю)'), $choices);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down
Expand Up @@ -31,19 +31,19 @@ public function testThrottling()

$start = time();
$transport->send($message, $envelope);
$this->assertEquals(0, time() - $start, '', 1);
$this->assertEqualsWithDelta(0, time() - $start, 1);
$transport->send($message, $envelope);
$this->assertEquals(5, time() - $start, '', 1);
$this->assertEqualsWithDelta(5, time() - $start, 1);
$transport->send($message, $envelope);
$this->assertEquals(10, time() - $start, '', 1);
$this->assertEqualsWithDelta(10, time() - $start, 1);
$transport->send($message, $envelope);
$this->assertEquals(15, time() - $start, '', 1);
$this->assertEqualsWithDelta(15, time() - $start, 1);

$start = time();
$transport->setMaxPerSecond(-3);
$transport->send($message, $envelope);
$this->assertEquals(0, time() - $start, '', 1);
$this->assertEqualsWithDelta(0, time() - $start, 1);
$transport->send($message, $envelope);
$this->assertEquals(0, time() - $start, '', 1);
$this->assertEqualsWithDelta(0, time() - $start, 1);
}
}
Expand Up @@ -22,7 +22,7 @@ class HandlersLocatorTest extends TestCase
{
public function testItYieldsHandlerDescriptors()
{
$handler = $this->createPartialMock(\stdClass::class, ['__invoke']);
$handler = $this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']);
$locator = new HandlersLocator([
DummyMessage::class => [$handler],
]);
Expand All @@ -32,13 +32,13 @@ public function testItYieldsHandlerDescriptors()

public function testItReturnsOnlyHandlersMatchingTransport()
{
$firstHandler = $this->createPartialMock(\stdClass::class, ['__invoke']);
$secondHandler = $this->createPartialMock(\stdClass::class, ['__invoke']);
$firstHandler = $this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']);
$secondHandler = $this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']);

$locator = new HandlersLocator([
DummyMessage::class => [
$first = new HandlerDescriptor($firstHandler, ['alias' => 'one']),
new HandlerDescriptor($this->createPartialMock(\stdClass::class, ['__invoke']), ['from_transport' => 'ignored', 'alias' => 'two']),
new HandlerDescriptor($this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']), ['from_transport' => 'ignored', 'alias' => 'two']),
$second = new HandlerDescriptor($secondHandler, ['from_transport' => 'transportName', 'alias' => 'three']),
],
]);
Expand All @@ -51,3 +51,11 @@ public function testItReturnsOnlyHandlersMatchingTransport()
)));
}
}

class HandlersLocatorTestCallable
{
public function __invoke()
{

}
}
Expand Up @@ -42,7 +42,7 @@ public function testExecuteMiddlewareOnActivatedWithCallable()
$message = new DummyMessage('Hello');
$envelope = new Envelope($message);

$activated = $this->createPartialMock(\stdClass::class, ['__invoke']);
$activated = $this->createPartialMock(ActivationMiddlewareTestCallable::class, ['__invoke']);
$activated->expects($this->once())->method('__invoke')->with($envelope)->willReturn(true);

$stack = $this->getStackMock(false);
Expand All @@ -68,3 +68,10 @@ public function testExecuteMiddlewareOnDeactivated()
$decorator->handle($envelope, $this->getStackMock());
}
}

class ActivationMiddlewareTestCallable
{
public function __invoke()
{
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php
Expand Up @@ -87,7 +87,7 @@ public function testStop()
$event = $stopwatch->stop('foo');

$this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event);
$this->assertEquals(200, $event->getDuration(), '', self::DELTA);
$this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA);
}

public function testUnknownEvent()
Expand Down

0 comments on commit 914a800

Please sign in to comment.