Compare commits

..

No commits in common. "e66350b72662fc6ba80d30c4063a30308e9e0fc3" and "2107a6f8e62945aac87716e54621cbef9a27c324" have entirely different histories.

7 changed files with 14 additions and 43 deletions

18
test.sh
View file

@ -1,18 +0,0 @@
#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
DIR="$(realpath ${0%/*})"
RUNTIME_IS_PODMAN="false"
if [[ -x "$(which podman)" ]]; then
CONTAINER_RUNTIME="$(which podman 2> /dev/null)"
RUNTIME_IS_PODMAN="true"
elif [[ -x "$(which docker)" ]]; then
CONTAINER_RUNTIME="$(which docker 2> /dev/null)"
else
echo "Container runtime (docker/podman) not found!"
exit 1
fi
$CONTAINER_RUNTIME exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make test'

View file

@ -9,6 +9,7 @@ use OCP\AppFramework\App;
use OCP\IRequest; use OCP\IRequest;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class MatrixTicketIntegrationTest extends TestCase { class MatrixTicketIntegrationTest extends TestCase {
private $controller; private $controller;
private $mapper; private $mapper;

View file

@ -8,6 +8,7 @@ use OCP\AppFramework\App;
use OCP\IRequest; use OCP\IRequest;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class MatrixUserIntegrationTest extends TestCase { class MatrixUserIntegrationTest extends TestCase {
private $mapper; private $mapper;
private $userId = 'john'; private $userId = 'john';

View file

@ -3,12 +3,13 @@
namespace OCA\UPschooling\Tests\Unit\Controller; namespace OCA\UPschooling\Tests\Unit\Controller;
use OCA\UPschooling\Controller\TicketApiController; use OCA\UPschooling\Controller\TicketApiController;
use OCA\UPschooling\Service\NoteNotFound;
use OCA\UPschooling\Service\TicketService; use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\IRequest; use OCP\IRequest;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class TicketApiControllerTest extends TestCase class NoteApiControllerTest extends TestCase
{ {
protected $controller; protected $controller;
protected $service; protected $service;
@ -40,7 +41,7 @@ class TicketApiControllerTest extends TestCase
$this->assertEquals($note, $result->getData()); $this->assertEquals($note, $result->getData());
} }
/*
public function testUpdateNotFound() public function testUpdateNotFound()
{ {
// test the correct status code if no note is found // test the correct status code if no note is found
@ -51,5 +52,5 @@ class TicketApiControllerTest extends TestCase
$result = $this->controller->update(3); $result = $this->controller->update(3);
$this->assertEquals(Http::STATUS_NOT_FOUND, $result->getStatus()); $this->assertEquals(Http::STATUS_NOT_FOUND, $result->getStatus());
}*/ }
} }

View file

@ -1,8 +1,7 @@
<?php <?php
namespace OCA\UPschooling\Tests\Unit\Controller; namespace OCA\UPschooling\Controller;
use OCA\UPschooling\Controller\PageController;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View file

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\UPschooling\Tests\Unit\Service; namespace Unit\Service;
use OCA\UPschooling\Db\MatrixTicket; use OCA\UPschooling\Db\MatrixTicket;
use OCA\UPschooling\Db\TicketMapper; use OCA\UPschooling\Db\TicketMapper;
@ -11,7 +11,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
class TicketServiceTest extends TestCase { class NoteServiceTest extends TestCase {
/** @var TicketService */ /** @var TicketService */
private $service; private $service;
@ -43,6 +43,8 @@ class TicketServiceTest extends TestCase {
// the existing note // the existing note
$note = MatrixTicket::fromRow([ $note = MatrixTicket::fromRow([
'id' => 3, 'id' => 3,
'title' => 'yo',
'content' => 'nope'
]); ]);
$this->ticketMapper->expects($this->once()) $this->ticketMapper->expects($this->once())
->method('find') ->method('find')
@ -51,6 +53,8 @@ class TicketServiceTest extends TestCase {
// the note when updated // the note when updated
$updatedNote = MatrixTicket::fromRow(['id' => 3]); $updatedNote = MatrixTicket::fromRow(['id' => 3]);
$updatedNote->setTitle('title');
$updatedNote->setContent('content');
$this->ticketMapper->expects($this->once()) $this->ticketMapper->expects($this->once())
->method('update') ->method('update')
->with($this->equalTo($updatedNote)) ->with($this->equalTo($updatedNote))

View file

@ -1,20 +1,3 @@
<?php <?php
define('PHPUNIT_RUN', 1); require_once __DIR__ . '/../tests/bootstrap.php';
$configDir = getenv('CONFIG_DIR');
if ($configDir) {
define('PHPUNIT_CONFIG_DIR', $configDir);
}
require_once __DIR__ . '/../../../lib/base.php';
\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true);
\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/', true);
// load all enabled apps
\OC_App::loadApps();
OC_Hook::clear();
set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/php');