Test Failed
Push — master ( 324182...871a01 )
by
unknown
11:38
created

GrommunioDavBackendTest::ObjectUriProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
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
 * @coversNothing
15
 */
16
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...
17
	protected $gDavBackend;
18
19
	/**
20
	 * {@inheritDoc}
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
	 * {@inheritDoc}
31
	 *
32
	 * @see PHPUnit_Framework_TestCase::tearDown()
33
	 */
34
	protected function tearDown() {
35
		$this->gDavBackend = null;
36
	}
37
38
	/**
39
	 * Tests if the constructor is created without errors.
40
	 */
41
	public function testConstruct() {
42
		$this->assertTrue(is_object($this->gDavBackend));
43
	}
44
45
	/**
46
	 * Tests the GetObjectIdFromObjectUri function.
47
	 *
48
	 * @param string $objectUri
49
	 * @param string $extension
50
	 * @param string $expected
51
	 *
52
	 * @dataProvider ObjectUriProvider
53
	 */
54
	public function testGetObjectIdFromObjectUri($objectUri, $extension, $expected) {
55
		$this->assertEquals($expected, $this->gDavBackend->GetObjectIdFromObjectUri($objectUri, $extension));
56
	}
57
58
	/**
59
	 * Provides data for testGetObjectIdFromObjectUri.
60
	 *
61
	 * @return array
62
	 */
63
	public function ObjectUriProvider() {
64
		return [
65
			['1234.ics', '.ics', '1234'],               // ok, cut .ics
66
			['5678AF.vcf', '.vcf', '5678AF'],           // ok, cut .vcf
67
			['123400.vcf', '.ics', '123400.vcf'],       // different extension, return as is
68
			['1234.ics', '.vcf', '1234.ics'],            // different extension, return as is
69
		];
70
	}
71
}
72