8000 minor #18286 [2.7] fix mocking of some methods (xabbuh) · symfony/symfony@d31d92e · GitHub
[go: up one dir, main page]

Skip to content

Commit d31d92e

Browse files
committed
minor #18286 [2.7] fix mocking of some methods (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [2.7] fix mocking of some methods | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | items 6 and 8 of sebastianbergmann/phpunit-mock-objects#299 (comment) | License | MIT | Doc PR | Commits ------- a45b93d [2.7] fix mocking of some methods
2 parents bd6d9bb + a45b93d commit d31d92e

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function testClassCacheIsLoaded()
9999

100100
public function testClassCacheIsNotLoadedByDefault()
101101
{
102-
$kernel = $this->getKernel(array('initializeBundles', 'initializeContainer'));
102+
$kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache'));
103103
$kernel->expects($this->never())
104104
->method('doLoadClassCache');
105105

src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Translation\Tests\Writer;
1313

14+
use Symfony\Component\Translation\Dumper\DumperInterface;
1415
use Symfony\Component\Translation\MessageCatalogue;
1516
use Symfony\Component\Translation\Writer\TranslationWriter;
1617

@@ -30,18 +31,35 @@ public function testWriteTranslations()
3031

3132
public function testDisableBackup()
3233
{
33-
$dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface');
34-
$dumper
35-
->expects($this->never())
36-
->method('setBackup');
37-
$phpDumper = $this->getMock('Symfony\Component\Translation\Dumper\PhpFileDumper');
38-
$phpDumper
39-
->expects($this->once())
40-
->method('setBackup');
34+
$nonBackupDumper = new NonBackupDumper();
35+
$backupDumper = new BackupDumper();
4136

4237
$writer = new TranslationWriter();
43-
$writer->addDumper('test', $dumper);
44-
$writer->addDumper('php', $phpDumper);
38+
$writer->addDumper('non_backup', $nonBackupDumper);
39+
$writer->addDumper('backup', $backupDumper);
4540
$writer->disableBackup();
41+
42+
$this->assertFalse($backupDumper->backup, 'backup can be disabled if setBackup() method does exist');
43+
}
44+
}
45+
46+
class NonBackupDumper implements DumperInterface
47+
{
48+
public function dump(MessageCatalogue $messages, $options = array())
49+
{
50+
}
51+
}
52+
53+
class BackupDumper implements DumperInterface
54+
{
55+
public $backup = true;
56+
57+
public function dump(MessageCatalogue $messages, $options = array())
58+
{
59+
}
60+
61+
public function setBackup($backup)
62+
{
63+
$this->backup = $backup;
4664
}
4765
}

0 commit comments

Comments
 (0)
0