diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-02-23 15:42:18 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-02-25 15:09:41 +0100 |
commit | 9873ab20afde7def037dcee2e00921d01e52ae82 (patch) | |
tree | b03607b2f359b91a358b1267042e9d2bd0e8e79a /tests/lib/command | |
parent | 27d047979d2fd5e77ef14386dd575607c4041990 (diff) | |
download | nextcloud-server-9873ab20afde7def037dcee2e00921d01e52ae82.tar.gz nextcloud-server-9873ab20afde7def037dcee2e00921d01e52ae82.zip |
prevent phpunit from messing with the bound $this
Diffstat (limited to 'tests/lib/command')
-rw-r--r-- | tests/lib/command/asyncbus.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/lib/command/asyncbus.php b/tests/lib/command/asyncbus.php index d22ce34d839..183eaa29c37 100644 --- a/tests/lib/command/asyncbus.php +++ b/tests/lib/command/asyncbus.php @@ -10,6 +10,7 @@ namespace Test\Command; use OC\Command\FileAccess; +use OCP\Command\IBus; use OCP\Command\ICommand; use Test\BackgroundJob\DummyJobList; use Test\TestCase; @@ -44,6 +45,19 @@ function basicFunction() { AsyncBus::$lastCommand = 'function'; } +// clean class to prevent phpunit putting closure in $this +class ThisClosureTest { + private function privateMethod() { + AsyncBus::$lastCommand = 'closure-this'; + } + + public function test(IBus $bus) { + $bus->push(function () { + $this->privateMethod(); + }); + } +} + class AsyncBus extends TestCase { /** * Basic way to check output from a command @@ -121,14 +135,11 @@ class AsyncBus extends TestCase { $this->assertEquals('closure-self', self::$lastCommand); } - private function privateMethod() { - self::$lastCommand = 'closure-this'; - } public function testClosureThis() { - $this->bus->push(function () { - $this->privateMethod(); - }); + // clean class to prevent phpunit putting closure in $this + $test = new ThisClosureTest(); + $test->test($this->bus); $this->runJobs(); $this->assertEquals('closure-this', self::$lastCommand); } |