Skip to content

Commit

Permalink
Added phpstan for tests folder (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVanOort authored and staabm committed Jan 4, 2020
1 parent 26673bb commit 82d2d6a
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
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
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
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
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
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
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
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
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

0 comments on commit 82d2d6a

Please sign in to comment.