Skip to content

Commit

Permalink
Merge pull request #1240 from phil-davis/standardize-ci
Browse files Browse the repository at this point in the history
Standardize CI
  • Loading branch information
phil-davis authored Feb 7, 2020
2 parents 3aa6505 + 94baa7e commit 5857a0d
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 246 deletions.
11 changes: 0 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ composer.lock
vendor

# Composer binaries
bin/phing
bin/phpunit
bin/vobject
bin/generate_vcards
bin/phpdocmd
bin/phpstan
bin/phpstan.phar
bin/php-cs-fixer

# Assuming every .php file in the root is for testing
/*.php
Expand All @@ -42,10 +37,4 @@ build.properties
docs/api
docs/wikidocs

# Mac
.DS_Store

.php_cs.cache

# IDEs
/.idea
18 changes: 8 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,37 @@ env:
- SABRE_MYSQLDSN="mysql:host=127.0.0.1;dbname=sabredav_test"
- RUN_PHPSTAN="FALSE"
matrix:
- LOWEST_DEPS="" TEST_DEPS="" WITH_COVERAGE="--coverage-clover=coverage.xml"
- LOWEST_DEPS="--prefer-lowest" TEST_DEPS="tests/Sabre/" $WITH_COVERAGE=""
- PREFER_LOWEST="" TEST_DEPS="" WITH_COVERAGE="--coverage-clover=coverage.xml"
- PREFER_LOWEST="--prefer-lowest" TEST_DEPS="tests/Sabre/" $WITH_COVERAGE=""

matrix:
include:
- name: 'PHPStan'
php: 7.2
php: 7.4
env: RUN_PHPSTAN="TRUE"
- name: 'Test with streaming propfind'
php: 7.2
env: RUN_TEST_WITH_STREAMING_PROPFIND="TRUE"
fast_finish: true

services:
- mysql
- postgresql

install:
- if [ $RUN_PHPSTAN == "TRUE" ]; then composer require --dev phpstan/phpstan:^0.12; fi

before_script:
- mysql -u root -h 127.0.0.1 -e 'create database sabredav_test'
- psql -c "create database sabredav_test" -U postgres
- psql -c "create user sabredav with PASSWORD 'sabredav';GRANT ALL PRIVILEGES ON DATABASE sabredav_test TO sabredav" -U postgres
- composer update --prefer-dist $LOWEST_DEPS
- composer update $PREFER_LOWEST

addons:
postgresql: "9.5"

script:
- if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/php-cs-fixer fix --dry-run --diff; fi
- if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --verbose --configuration tests/phpunit.xml $WITH_COVERAGE $TEST_DEPS; fi
- if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi
- if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE $TEST_DEPS; fi
- if [ $RUN_PHPSTAN == "FALSE" ]; then rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi
- if [ $RUN_PHPSTAN == "TRUE" ]; then php ./bin/phpstan analyse -c phpstan.neon lib; fi
- if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
34 changes: 24 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
"require-dev" : {
"friendsofphp/php-cs-fixer": "~2.16.1",
"phpunit/phpunit" : "^7.5 || ^8.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit" : "^7.5 || ^8.5",
"evert/phpdoc-md" : "~0.1.0",
"monolog/monolog": "^1.18"
},
Expand All @@ -53,13 +54,13 @@
},
"autoload-dev" : {
"psr-4" : {
"Sabre\\" : "tests/sabre/",
"Sabre\\CalDAV\\" : "tests/sabre/CalDAV",
"Sabre\\CardDAV\\" : "tests/sabre/CardDAV",
"Sabre\\DAV\\" : "tests/sabre/DAV",
"Sabre\\DAV\\Property\\" : "tests/sabre/DAV/Xml/Property",
"Sabre\\DAVACL\\" : "tests/sabre/DAVACL",
"Sabre\\HTTP\\" : "tests/sabre/HTTP"
"Sabre\\" : "tests/Sabre/",
"Sabre\\CalDAV\\" : "tests/Sabre/CalDAV",
"Sabre\\CardDAV\\" : "tests/Sabre/CardDAV",
"Sabre\\DAV\\" : "tests/Sabre/DAV",
"Sabre\\DAV\\Property\\" : "tests/Sabre/DAV/Xml/Property",
"Sabre\\DAVACL\\" : "tests/Sabre/DAVACL",
"Sabre\\HTTP\\" : "tests/Sabre/HTTP"
}
},
"support" : {
Expand All @@ -70,7 +71,20 @@
"bin/sabredav",
"bin/naturalselection"
],
"config" : {
"bin-dir" : "./bin"
"scripts": {
"phpstan": [
"phpstan analyse lib tests"
],
"cs-fixer": [
"php-cs-fixer fix"
],
"phpunit": [
"phpunit --configuration tests/phpunit.xml"
],
"test": [
"composer phpstan",
"composer cs-fixer",
"composer phpunit"
]
}
}
4 changes: 4 additions & 0 deletions tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class FreeBusyRequestTest extends \PHPUnit\Framework\TestCase
protected $request;
protected $authPlugin;
protected $caldavBackend;
/**
* @var HTTP\ResponseMock
*/
private $response;

public function setup(): void
{
Expand Down
4 changes: 4 additions & 0 deletions tests/Sabre/CalDAV/Schedule/SchedulingObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class SchedulingObjectTest extends \PHPUnit\Framework\TestCase
* @var Sabre\CalDAV\Calendar
*/
protected $calendar;
/**
* @var Inbox
*/
protected $inbox;
protected $principalBackend;

protected $data;
Expand Down
9 changes: 5 additions & 4 deletions tests/Sabre/CalDAV/SharingPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

use Sabre\DAV;
use Sabre\DAV\Xml\Element\Sharee;
use Sabre\DAVServerTest;
use Sabre\HTTP;

class SharingPluginTest extends \Sabre\DAVServerTest
class SharingPluginTest extends DAVServerTest
{
protected $setupCalDAV = true;
protected $setupCalDAVSharing = true;
Expand Down Expand Up @@ -178,7 +179,7 @@ public function testShareRequest()

$request->setBody($xml);

$response = $this->request($request, 200);
$this->request($request, 200);

$this->assertEquals(
[
Expand Down Expand Up @@ -228,7 +229,7 @@ public function testShareRequestNoShareableCalendar()

$request->setBody($xml);

$response = $this->request($request, 403);
$this->request($request, 403);
}

public function testInviteReply()
Expand Down Expand Up @@ -287,7 +288,7 @@ public function testInviteWrongUrl()

// If the plugin did not handle this request, it must ensure that the
// body is still accessible by other plugins.
$this->assertEquals($xml, $request->getBody(true));
$this->assertEquals($xml, $request->getBody());
}

public function testPostWithoutContentType()
Expand Down
83 changes: 0 additions & 83 deletions tests/Sabre/CalDAV/TestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,87 +99,4 @@ public static function getTestCalendarData($type = 1)

return $calendarData;
}

public static function getTestTODO($type = 'due')
{
switch ($type) {
case 'due':
$extra = 'DUE:20100104T000000Z';
break;
case 'due2':
$extra = 'DUE:20060104T000000Z';
break;
case 'due_date':
$extra = 'DUE;VALUE=DATE:20060104';
break;
case 'due_tz':
$extra = 'DUE;TZID=Asia/Seoul:20060104T000000Z';
break;
case 'due_dtstart':
$extra = "DTSTART:20050223T060000Z\nDUE:20060104T000000Z";
break;
case 'due_dtstart2':
$extra = "DTSTART:20090223T060000Z\nDUE:20100104T000000Z";
break;
case 'dtstart':
$extra = 'DTSTART:20100223T060000Z';
break;
case 'dtstart2':
$extra = 'DTSTART:20060223T060000Z';
break;
case 'dtstart_date':
$extra = 'DTSTART;VALUE=DATE:20100223';
break;
case 'dtstart_tz':
$extra = 'DTSTART;TZID=Asia/Seoul:20100223T060000Z';
break;
case 'dtstart_duration':
$extra = "DTSTART:20061023T060000Z\nDURATION:PT1H";
break;
case 'dtstart_duration2':
$extra = "DTSTART:20101023T060000Z\nDURATION:PT1H";
break;
case 'completed':
$extra = 'COMPLETED:20060601T000000Z';
break;
case 'completed2':
$extra = 'COMPLETED:20090601T000000Z';
break;
case 'created':
$extra = 'CREATED:20060601T000000Z';
break;
case 'created2':
$extra = 'CREATED:20090601T000000Z';
break;
case 'completedcreated':
$extra = "CREATED:20060601T000000Z\nCOMPLETED:20070101T000000Z";
break;
case 'completedcreated2':
$extra = "CREATED:20090601T000000Z\nCOMPLETED:20100101T000000Z";
break;
case 'notime':
$extra = 'X-FILLER:oh hello';
break;
default:
throw new Exception('Unknown type: '.$type);
}

$todo = 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VTODO
DTSTAMP:20060205T235335Z
'.$extra.'
STATUS:NEEDS-ACTION
SUMMARY:Task #1
UID:[email protected]
BEGIN:VALARM
ACTION:AUDIO
TRIGGER;RELATED=START:-PT10M
END:VALARM
END:VTODO
END:VCALENDAR';

return $todo;
}
}
63 changes: 0 additions & 63 deletions tests/Sabre/CardDAV/TestUtil.php

This file was deleted.

5 changes: 4 additions & 1 deletion tests/Sabre/DAV/Mock/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ public function getName()
*
* @return string|null
*/
public function createFile($name, $data = '')
public function createFile($name, $data = null)
{
if (null === $data) {
$data = '';
}
if (is_resource($data)) {
$data = stream_get_contents($data);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Sabre/DAV/SimpleCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public function testGetChild404()
{
$this->expectException('Sabre\DAV\Exception\NotFound');
$s = new SimpleCollection('foo', []);
$this->assertEquals($s->getChild('404'));
$s->getChild('404');
}
}
Loading

0 comments on commit 5857a0d

Please sign in to comment.