testGetObjectIdFromObjectUri()   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 3
dl 0
loc 2
rs 10
1
<?php
2
/*
3
 * SPDX-License-Identifier: AGPL-3.0-only
4
 * SPDX-FileCopyrightText: Copyright 2016 - 2018 Kopano b.v.
5
 * SPDX-FileCopyrightText: Copyright 2020 grommunio GmbH
6
 *
7
 * Tests for grommunio DAV backend class which handles grommunio related activities.
8
 */
9
10
namespace grommunio\DAV;
11
12
/**
13
 * @internal
14
 *
15
 * @coversNothing
16
 */
17
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...
18
	protected $gDavBackend;
19
20
	/**
21
	 * {@inheritDoc}
22
	 *
23
	 * @see PHPUnit_Framework_TestCase::setUp()
24
	 */
25
	protected function setUp() {
26
		$gloggerMock = $this->getMockBuilder(GLogger::class)->disableOriginalConstructor()->getMock();
27
		$this->gDavBackend = new GrommunioDavBackend($gloggerMock);
28
	}
29
30
	/**
31
	 * {@inheritDoc}
32
	 *
33
	 * @see PHPUnit_Framework_TestCase::tearDown()
34
	 */
35
	protected function tearDown() {
36
		$this->gDavBackend = null;
37
	}
38
39
	/**
40
	 * Tests if the constructor is created without errors.
41
	 */
42
	public function testConstruct() {
43
		$this->assertTrue(is_object($this->gDavBackend));
44
	}
45
46
	/**
47
	 * Tests the GetObjectIdFromObjectUri function.
48
	 *
49
	 * @param string $objectUri
50
	 * @param string $extension
51
	 * @param string $expected
52
	 *
53
	 * @dataProvider ObjectUriProvider
54
	 */
55
	public function testGetObjectIdFromObjectUri($objectUri, $extension, $expected) {
56
		$this->assertEquals($expected, $this->gDavBackend->GetObjectIdFromObjectUri($objectUri, $extension));
57
	}
58
59
	/**
60
	 * Provides data for testGetObjectIdFromObjectUri.
61
	 *
62
	 * @return array
63
	 */
64
	public function ObjectUriProvider() {
65
		return [
66
			['1234.ics', '.ics', '1234'],               // ok, cut .ics
67
			['5678AF.vcf', '.vcf', '5678AF'],           // ok, cut .vcf
68
			['123400.vcf', '.ics', '123400.vcf'],       // different extension, return as is
69
			['1234.ics', '.vcf', '1234.ics'],            // different extension, return as is
70
		];
71
	}
72
}
73