summaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-01-24 18:10:16 +0100
committerJoas Schilling <coding@schilljs.com>2018-01-24 18:10:16 +0100
commit870023365c928e6bc3bd39d0d7f9b4d976dad33e (patch)
tree74c1438392d2101c154a80d4f4b9d4777c77bd1a /tests/lib/AppFramework
parentc3424df1f026854ed8adbfdf8d96da7a6562a8dd (diff)
downloadnextcloud-server-870023365c928e6bc3bd39d0d7f9b4d976dad33e.tar.gz
nextcloud-server-870023365c928e6bc3bd39d0d7f9b4d976dad33e.zip
Fix "Undefined method setExpectedException()"
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/AppFramework')
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php17
-rw-r--r--tests/lib/AppFramework/Db/MapperTest.php16
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php4
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php4
6 files changed, 25 insertions, 24 deletions
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index e1a3d7533be..c9a90da7c59 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -46,7 +46,7 @@ class TestEntity extends Entity {
protected $preName;
public function __construct($name=null){
- $this->addType('testId', 'integer');
+ $this->addType('testId', 'integer');
$this->name = $name;
}
};
@@ -119,23 +119,26 @@ class EntityTest extends \Test\TestCase {
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testCallShouldOnlyWorkForGetterSetter(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->something();
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testGetterShouldFailIfAttributeNotDefined(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->getTest();
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testSetterShouldFailIfAttributeNotDefined(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->setTest();
}
diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php
index 108e4eee28e..990391a1de1 100644
--- a/tests/lib/AppFramework/Db/MapperTest.php
+++ b/tests/lib/AppFramework/Db/MapperTest.php
@@ -24,6 +24,8 @@
namespace Test\AppFramework\Db;
+use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use \OCP\IDBConnection;
use \OCP\AppFramework\Db\Entity;
use \OCP\AppFramework\Db\Mapper;
@@ -95,8 +97,7 @@ class MapperTest extends MapperTestUtility {
$params = array('jo');
$rows = array();
$this->setMapperResult($sql, $params, $rows);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\DoesNotExistException');
+ $this->expectException(DoesNotExistException::class);
$this->mapper->find($sql, $params);
}
@@ -105,8 +106,7 @@ class MapperTest extends MapperTestUtility {
$params = array('jo');
$rows = array();
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\DoesNotExistException');
+ $this->expectException(DoesNotExistException::class);
$this->mapper->findOneEntity($sql, $params);
}
@@ -117,8 +117,7 @@ class MapperTest extends MapperTestUtility {
array('jo'), array('ho')
);
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->expectException(MultipleObjectsReturnedException::class);
$this->mapper->find($sql, $params);
}
@@ -129,8 +128,7 @@ class MapperTest extends MapperTestUtility {
array('jo'), array('ho')
);
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->expectException(MultipleObjectsReturnedException::class);
$this->mapper->findOneEntity($sql, $params);
}
@@ -223,7 +221,7 @@ class MapperTest extends MapperTestUtility {
$entity->setPreName($params[0]);
$entity->setEmail($params[1]);
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->mapper->update($entity);
}
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index eb08d00e358..95fa3c2a047 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -267,7 +267,7 @@ class DispatcherTest extends \Test\TestCase {
$responseHeaders = array('hell' => 'yeah');
$this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders, true, false);
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$response = $this->dispatcher->dispatch($this->controller,
$this->controllerMethod);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index e71be9c5f16..b2f78c17fe6 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -177,7 +177,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
$this->dispatcher->registerMiddleware($m1);
$this->dispatcher->registerMiddleware($m2);
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
}
@@ -206,7 +206,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
public function testAfterExceptionCorrectArguments(){
$m1 = $this->getMiddleware();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
@@ -253,7 +253,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
$m1 = $this->getMiddleware();
$m2 = $this->getMiddleware();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index 07028745676..038bec25148 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -75,8 +75,8 @@ class MiddlewareTest extends \Test\TestCase {
public function testAfterExceptionRaiseAgainWhenUnhandled() {
- $this->setExpectedException('Exception');
- $afterEx = $this->middleware->afterException($this->controller, null, $this->exception);
+ $this->expectException(\Exception::class);
+ $this->middleware->afterException($this->controller, null, $this->exception);
}
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 0d7418673dd..274a2810cba 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -263,7 +263,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$sec = $this->getMiddleware($isLoggedIn, $isAdminUser);
if($shouldFail) {
- $this->setExpectedException('\OC\AppFramework\Middleware\Security\Exceptions\SecurityException');
+ $this->expectException(SecurityException::class);
} else {
$this->assertTrue(true);
}
@@ -454,7 +454,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
public function testAfterExceptionNotCaughtThrowsItAgain(){
$ex = new \Exception();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->middleware->afterException($this->controller, 'test', $ex);
}