Skip to content

Instantly share code, notes, and snippets.

@koertho
Last active March 14, 2018 10:24
Show Gist options
  • Select an option

  • Save koertho/166b6e9e0b34b28a0440180f6deb64a7 to your computer and use it in GitHub Desktop.

Select an option

Save koertho/166b6e9e0b34b28a0440180f6deb64a7 to your computer and use it in GitHub Desktop.
Test original method without using the constructor in PHPUnit (usefull for Model or Module testing in Contao)
<?php
class ModelTest extends TestCase
{
public function getModelMock ()
{
// The key is the null value to setMethod (default is [] which mocks all methods).
$model = $this->getMockBuilder(FieldPaletteModel::class)->setMethods(null)->disableOriginalConstructor()->getMock();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment