Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 36... Línea 36...
36
 * Class repository_nextcloud_lib_testcase
36
 * Class repository_nextcloud_lib_testcase
37
 * @group repository_nextcloud
37
 * @group repository_nextcloud
38
 * @copyright  2017 Project seminar (Learnweb, University of Münster)
38
 * @copyright  2017 Project seminar (Learnweb, University of Münster)
39
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
40
 */
41
class lib_test extends \advanced_testcase {
41
final class lib_test extends \advanced_testcase {
Línea 42... Línea 42...
42
 
42
 
43
    /** @var null|\repository_nextcloud the repository_nextcloud object, which the tests are run on. */
43
    /** @var null|\repository_nextcloud the repository_nextcloud object, which the tests are run on. */
Línea 44... Línea 44...
44
    private $repo = null;
44
    private $repo = null;
Línea 48... Línea 48...
48
 
48
 
49
    /**
49
    /**
50
     * SetUp to create an repository instance.
50
     * SetUp to create an repository instance.
51
     */
51
     */
-
 
52
    protected function setUp(): void {
52
    protected function setUp(): void {
53
        parent::setUp();
Línea 53... Línea 54...
53
        $this->resetAfterTest(true);
54
        $this->resetAfterTest(true);
54
 
55
 
Línea 850... Línea 851...
850
    /**
851
    /**
851
     * This function provides the data for test_sync_reference
852
     * This function provides the data for test_sync_reference
852
     *
853
     *
853
     * @return array[]
854
     * @return array[]
854
     */
855
     */
855
    public function sync_reference_provider(): array {
856
    public static function sync_reference_provider(): array {
856
        return [
857
        return [
857
            'referecncelastsync done recently' => [
858
            'referecncelastsync done recently' => [
858
                [
859
                [
859
                    'storedfile_record' => [
860
                    'storedfile_record' => [
860
                            'contextid' => \context_system::instance()->id,
861
                            'contextid' => \context_system::instance()->id,
Línea 945... Línea 946...
945
    /**
946
    /**
946
     * Testing sync_reference
947
     * Testing sync_reference
947
     *
948
     *
948
     * @dataProvider sync_reference_provider
949
     * @dataProvider sync_reference_provider
949
     * @param array $storedfileargs
950
     * @param array $storedfileargs
950
     * @param array $storedfilemethodsmock
951
     * @param array $mockfunctions
951
     * @param bool $expectedresult
952
     * @param bool $expectedresult
952
     * @return void
953
     * @return void
953
     */
954
     */
954
    public function test_sync_reference(array $storedfileargs, $storedfilemethodsmock, bool $expectedresult): void {
955
    public function test_sync_reference(array $storedfileargs, $mockfunctions, bool $expectedresult): void {
955
        $this->resetAfterTest(true);
956
        $this->resetAfterTest(true);
Línea 956... Línea 957...
956
 
957
 
957
        if (isset($storedfilemethodsmock[0])) {
958
        if (isset($mockfunctions[0])) {
Línea 958... Línea 959...
958
            $storedfile = $this->createMock(\stored_file::class);
959
            $storedfile = $this->createMock(\stored_file::class);
959
 
960
 
960
            if ($storedfilemethodsmock[0] === 'get_referencelastsync') {
961
            if ($mockfunctions[0] === 'get_referencelastsync') {
961
                if (!$expectedresult) {
962
                if (!$expectedresult) {
962
                    $storedfile->method('get_referencelastsync')->willReturn(DAYSECS + time());
963
                    $storedfile->method('get_referencelastsync')->willReturn(DAYSECS + time());
963
                }
964
                }