Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added phpstan for tests folder #485

Merged
merged 1 commit into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ before_script:
- composer install

script:
- if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then php phpstan.phar analyse -c phpstan.neon lib; fi
- if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then php phpstan.phar analyse -c phpstan.neon lib tests; fi
- ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml

after_success:
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"Sabre\\VObject\\" : "lib/"
}
},
"autoload-dev" : {
"psr-4" : {
"Sabre\\VObject\\" : "tests/VObject"
}
},
"bin" : [
"bin/vobject",
"bin/generate_vcards"
Expand Down
3 changes: 1 addition & 2 deletions lib/PHPUnitAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ trait PHPUnitAssertions
*/
public function assertVObjectEqualsVObject($expected, $actual, $message = '')
{
$self = $this;
$getObj = function ($input) use ($self) {
$getObj = function ($input) {
if (is_resource($input)) {
$input = stream_get_contents($input);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/VObject/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
class CliTest extends TestCase
{
/** @var CliMock */
private $cli;

public function setUp()
{
$this->cli = new CliMock();
Expand Down
6 changes: 3 additions & 3 deletions tests/VObject/Component/VCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function testNoUIDCardDAV()
VCF;
$this->assertValidate(
$vcard,
VCARD::PROFILE_CARDDAV,
VCard::PROFILE_CARDDAV,
3,
'vCards on CardDAV servers MUST have a UID property.'
);
Expand Down Expand Up @@ -236,7 +236,7 @@ public function testNoUIDNoCardDAVRepair()
VCF;
$this->assertValidate(
$vcard,
VCARD::REPAIR,
VCard::REPAIR,
1,
'Adding a UID to a vCard property is recommended.'
);
Expand All @@ -253,7 +253,7 @@ public function testVCard21CardDAV()
VCF;
$this->assertValidate(
$vcard,
VCARD::PROFILE_CARDDAV,
VCard::PROFILE_CARDDAV,
3,
'CardDAV servers are not allowed to accept vCard 2.1.'
);
Expand Down
2 changes: 1 addition & 1 deletion tests/VObject/FreeBusyGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testInvalidArg()
$gen = new FreeBusyGenerator(
new \DateTime('2012-01-01'),
new \DateTime('2012-12-31'),
new \StdClass()
new \stdClass()
);
}

Expand Down
42 changes: 21 additions & 21 deletions tests/VObject/JCalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public function testToJCal()
[
[
'version',
new \StdClass(),
new \stdClass(),
'text',
'2.0',
],
[
'prodid',
new \StdClass(),
new \stdClass(),
'text',
'-//Sabre//Sabre VObject '.Version::VERSION.'//EN',
],
[
'calscale',
new \StdClass(),
new \stdClass(),
'text',
'GREGORIAN',
],
Expand All @@ -64,22 +64,22 @@ public function testToJCal()
['vevent',
[
[
'uid', new \StdClass(), 'text', 'foo',
'uid', new \stdClass(), 'text', 'foo',
],
[
'dtstart', new \StdClass(), 'date', '2013-05-26',
'dtstart', new \stdClass(), 'date', '2013-05-26',
],
[
'duration', new \StdClass(), 'duration', 'P1D',
'duration', new \stdClass(), 'duration', 'P1D',
],
[
'categories', new \StdClass(), 'text', 'home', 'testing',
'categories', new \stdClass(), 'text', 'home', 'testing',
],
[
'created', new \StdClass(), 'date-time', '2013-05-26T18:10:00Z',
'created', new \stdClass(), 'date-time', '2013-05-26T18:10:00Z',
],
[
'attendee', new \StdClass(), 'cal-address', 'mailto:armin@example.org',
'attendee', new \stdClass(), 'cal-address', 'mailto:armin@example.org',
],
[
'attendee',
Expand All @@ -91,50 +91,50 @@ public function testToJCal()
'mailto:dominik@example.org',
],
[
'geo', new \StdClass(), 'float', [51.96668, 7.61876],
'geo', new \stdClass(), 'float', [51.96668, 7.61876],
],
[
'sequence', new \StdClass(), 'integer', 5,
'sequence', new \stdClass(), 'integer', 5,
],
[
'freebusy', new \StdClass(), 'period', ['2013-05-26T21:02:13', 'PT1H'], ['2013-06-26T12:00:00', '2013-06-26T13:00:00'],
'freebusy', new \stdClass(), 'period', ['2013-05-26T21:02:13', 'PT1H'], ['2013-06-26T12:00:00', '2013-06-26T13:00:00'],
],
[
'url', new \StdClass(), 'uri', 'http://example.org/',
'url', new \stdClass(), 'uri', 'http://example.org/',
],
[
'tzoffsetfrom', new \StdClass(), 'utc-offset', '+05:00',
'tzoffsetfrom', new \stdClass(), 'utc-offset', '+05:00',
],
[
'rrule', new \StdClass(), 'recur', [
'rrule', new \stdClass(), 'recur', [
'freq' => 'WEEKLY',
'byday' => ['MO', 'TU'],
],
],
[
'x-bool', new \StdClass(), 'boolean', true,
'x-bool', new \stdClass(), 'boolean', true,
],
[
'x-time', new \StdClass(), 'time', '08:00:00',
'x-time', new \stdClass(), 'time', '08:00:00',
],
[
'attach', new \StdClass(), 'binary', base64_encode('attachment'),
'attach', new \stdClass(), 'binary', base64_encode('attachment'),
],
[
'request-status',
new \StdClass(),
new \stdClass(),
'text',
['2.0', 'Success'],
],
[
'request-status',
new \StdClass(),
new \stdClass(),
'text',
['3.7', 'Invalid Calendar User', 'ATTENDEE:mailto:jsmith@example.org'],
],
[
'dtend',
new \StdClass(),
new \stdClass(),
'date-time',
'2015-01-08T13:30:00',
],
Expand Down
36 changes: 18 additions & 18 deletions tests/VObject/JCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ public function testToJCard()
[
[
'version',
new \StdClass(),
new \stdClass(),
'text',
'4.0',
],
[
'prodid',
new \StdClass(),
new \stdClass(),
'text',
'-//Sabre//Sabre VObject '.Version::VERSION.'//EN',
],
[
'uid',
new \StdClass(),
new \stdClass(),
'text',
'foo',
],
[
'bday',
new \StdClass(),
new \stdClass(),
'date-and-or-time',
'1985-04-07',
],
Expand All @@ -80,25 +80,25 @@ public function testToJCard()
],
[
'bday',
new \StdClass(),
new \stdClass(),
'date-time',
'1979-12-25T02:00:00',
],
[
'rev',
new \StdClass(),
new \stdClass(),
'timestamp',
'1995-10-31T22:27:10Z',
],
[
'lang',
new \StdClass(),
new \stdClass(),
'language-tag',
'nl',
],
[
'n',
new \StdClass(),
new \stdClass(),
'text',
['Last', 'First', 'Middle', '', ''],
],
Expand All @@ -120,7 +120,7 @@ public function testToJCard()
],
[
'adr',
new \StdClass(),
new \stdClass(),
'text',
[
'',
Expand All @@ -134,55 +134,55 @@ public function testToJCard()
],
[
'x-truncated',
new \StdClass(),
new \stdClass(),
'date',
'--12-25',
],
[
'x-time-local',
new \StdClass(),
new \stdClass(),
'time',
'12:30:00',
],
[
'x-time-utc',
new \StdClass(),
new \stdClass(),
'time',
'12:30:00Z',
],
[
'x-time-offset',
new \StdClass(),
new \stdClass(),
'time',
'12:30:00-08:00',
],
[
'x-time-reduced',
new \StdClass(),
new \stdClass(),
'time',
'23',
],
[
'x-time-truncated',
new \StdClass(),
new \stdClass(),
'time',
'--30',
],
[
'x-karma-points',
new \StdClass(),
new \stdClass(),
'integer',
42,
],
[
'x-grade',
new \StdClass(),
new \stdClass(),
'float',
1.3,
],
[
'tz',
new \StdClass(),
new \stdClass(),
'utc-offset',
'-05:00',
],
Expand Down
Loading