GrommunioDavBackendTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
/*
4
 * SPDX-License-Identifier: AGPL-3.0-only
5
 * SPDX-FileCopyrightText: Copyright 2016 - 2018 Kopano b.v.
6
 * SPDX-FileCopyrightText: Copyright 2020 grommunio GmbH
7
 *
8
 * Tests for grommunio DAV backend class which handles grommunio related activities.
9
 */
10
11
namespace grommunio\DAV;
12
13
/**
14
 * @internal
15
 *
16
 * @coversNothing
17
 */
18
class GrommunioDavBackendTest extends \PHPUnit_Framework_TestCase {
0 ignored issues
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
	protected $gDavBackend;
20
21
	/**
22
	 * @see PHPUnit_Framework_TestCase::setUp()
23
	 */
24
	protected function setUp() {
25
		$gloggerMock = $this->getMockBuilder(GLogger::class)->disableOriginalConstructor()->getMock();
26
		$this->gDavBackend = new GrommunioDavBackend($gloggerMock);
27
	}
28
29
	/**
30
	 * @see PHPUnit_Framework_TestCase::tearDown()
31
	 */
32
	protected function tearDown() {
33
		$this->gDavBackend = null;
34
	}
35
36
	/**
37
	 * Tests if the constructor is created without errors.
38
	 */
39
	public function testConstruct() {
40
		$this->assertTrue(is_object($this->gDavBackend));
41
	}
42
43
	/**
44
	 * Tests the GetObjectIdFromObjectUri function.
45
	 *
46
	 * @param string $objectUri
47
	 * @param string $extension
48
	 * @param string $expected
49
	 *
50
	 * @dataProvider ObjectUriProvider
51
	 */
52
	public function testGetObjectIdFromObjectUri($objectUri, $extension, $expected) {
53
		$this->assertEquals($expected, $this->gDavBackend->GetObjectIdFromObjectUri($objectUri, $extension));
54
	}
55
56
	/**
57
	 * Provides data for testGetObjectIdFromObjectUri.
58
	 *
59
	 * @return array
60
	 */
61
	public function ObjectUriProvider() {
62
		return [
63
			['1234.ics', '.ics', '1234'],               // ok, cut .ics
64
			['5678AF.vcf', '.vcf', '5678AF'],           // ok, cut .vcf
65
			['123400.vcf', '.ics', '123400.vcf'],       // different extension, return as is
66
			['1234.ics', '.vcf', '1234.ics'],            // different extension, return as is
67
		];
68
	}
69
}
70