Skip to content
Permalink
Browse files

Remove Mockery and (hopefully) fix travis builds

Replace Mockery with native PHPUnit test doubles support.
  • Loading branch information...
adobo committed Mar 11, 2017
1 parent 28d4879 commit fe86b7da678e1b6405111de006586991adcfc857
@@ -10,7 +10,7 @@ cache:
- $HOME/.composer/cache

script:
- phpunit --configuration tests/phpunit.xml
- ./vendor/bin/phpunit --configuration tests/phpunit.xml

before_script:
- composer install -d web/
@@ -2,7 +2,6 @@
namespace AgenDAV\CalDAV;
use Mockery as m;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Stream\Stream;
use GuzzleHttp\Client as GuzzleClient;
@@ -49,7 +48,7 @@ public function setUp()
{
$this->xml_generator = new Generator();
$this->xml_parser = new Parser();
$this->event_parser = m::mock('\AgenDAV\Event\Parser');
$this->event_parser = $this->createMock(\AgenDAV\Event\Parser::class);
$this->history = [];
}
@@ -508,11 +507,12 @@ public function testFetchObjectsFromCalendar()
Stream::factory($body)
);
$this->event_parser->shouldReceive('parse')
->times(2)
->andReturn(
m::mock('\AgenDAV\Event'),
m::mock('\AgenDAV\Event')
$this->event_parser
->expects($this->exactly(2))
->method('parse')
->willReturn(
$this->createMock(\AgenDAV\Event::class),
$this->createMock(\AgenDAV\Event::class)
);
$client = $this->createCalDAVClient($response);
@@ -604,11 +604,13 @@ public function testFetchEventByUidOK()
Stream::factory($body)
);
$this->event_parser->shouldReceive('parse')
->once()
->andReturn(
m::mock('\AgenDAV\Event')
$this->event_parser
->expects($this->once())
->method('parse')
->willReturn(
$this->createMock(\AgenDAV\Event::class)
);
$client = $this->createCalDAVClient($response);
$calendar = new Calendar('/cal.php/calendars/demo/fake');
@@ -628,10 +630,12 @@ public function testPutObjectNew()
// Twice: the first one for the upload, and the second one for
// the validity check
$event = m::mock('\AgenDAV\Event')
->shouldReceive('render')->times(2)
->andReturn('iCalendar resource')
->getMock();
$event = $this->createMock(\AgenDAV\Event::class);
$event
->expects($this->exactly(2))
->method('render')
->willReturn('iCalendar resource');
$object = new CalendarObject('/url', $event);
@@ -646,10 +650,11 @@ public function testPutObjectExisting()
// Twice: the first one for the upload, and the second one for
// the validity check
$event = m::mock('\AgenDAV\Event')
->shouldReceive('render')->times(2)
->andReturn('iCalendar resource')
->getMock();
$event = $this->createMock(\AgenDAV\Event::class);
$event
->expects($this->exactly(2))
->method('render')
->willReturn('iCalendar resource');
$object = new CalendarObject('/url', $event);
$object->setEtag('test_etag');
@@ -675,23 +680,23 @@ public function testACL()
$response = new Response(200);
$client = $this->createCalDAVClient($response);
$acl = m::mock('\AgenDAV\CalDAV\Share\ACL')
->shouldReceive('getOwnerPrivileges')
->andReturn([ '{DAV:}all' ]);
$acl = $this->createMock(\AgenDAV\CalDAV\Share\ACL::class);
$acl->method('getOwnerPrivileges')
->willReturn([ '{DAV:}all' ]);
$acl->shouldReceive('getDefaultPrivileges')
->andReturn(['{DAV:}minimal']);
$acl->method('getDefaultPrivileges')
->willReturn(['{DAV:}minimal']);
$acl->shouldReceive('getGrantsPrivileges')
->andReturn([
$acl->method('getGrantsPrivileges')
->willReturn([
'/u1' => ['{DAV:}write'],
'/u2' => ['{DAV:}read'],
]);
$calendar = new Calendar('/url');
$client->applyACL($calendar, $acl->getMock());
$this->validateACLRequest($calendar, $acl->getMock());
$client->applyACL($calendar, $acl);
$this->validateACLRequest($calendar, $acl);
}
/**
@@ -4,14 +4,13 @@
use AgenDAV\Data\Share;
use AgenDAV\Data\Principal;
use PHPUnit\Framework\TestCase;
use \Mockery as m;
class SharingResolverTest extends TestCase
{
public function testResolveShares()
{
$shares_repository = m::mock('\AgenDAV\Repositories\SharesRepository');
$principals_repository = m::mock('\AgenDAV\Repositories\PrincipalsRepository');
$shares_repository = $this->createMock(\AgenDAV\Repositories\SharesRepository::class);
$principals_repository = $this->createMock(\AgenDAV\Repositories\PrincipalsRepository::class);
$sharing_resolver = new SharingResolver(
$shares_repository,
$principals_repository
@@ -20,10 +19,11 @@ public function testResolveShares()
$principal = new Principal('/principals/test');
$principal->setDisplayName('Test principal');
$principals_repository->shouldReceive('get')
->once()
$principals_repository
->expects($this->once())
->method('get')
->with($principal->getUrl())
->andReturn($principal);
->willReturn($principal);
$share = new Share();
$share->setWith($principal->getUrl());
@@ -3,7 +3,6 @@
use AgenDAV\CalDAV\Resource\Calendar;
use PHPUnit\Framework\TestCase;
use \Mockery as m;
class ToolkitTest extends TestCase
{
@@ -22,17 +21,17 @@ class ToolkitTest extends TestCase
public function setUp()
{
$this->parser = m::mock('\AgenDAV\XML\Parser');
$this->generator = m::mock('\AgenDAV\XML\Generator');
$this->parser = $this->createMock(Parser::class);
$this->generator = $this->createMock(Generator::class);
}
public function testFacadeParseMultiStatus()
{
$this->parser
->shouldReceive('extractPropertiesFromMultistatus')
->once()
->expects($this->once())
->method('extractPropertiesFromMultistatus')
->with('body', false)
->andReturn(['result']);
->willReturn(['result']);
$toolkit = $this->createToolkit();
@@ -55,10 +54,10 @@ public function testGenerateBodyUnsupportedRequest()
public function testGenerateMkCalendarBody()
{
$this->generator
->shouldReceive('mkCalendarBody')
->once()
->expects($this->once())
->method('mkCalendarBody')
->with(self::$property_list)
->andReturn('result');
->willReturn('result');
$toolkit = $this->createToolkit();
$this->assertEquals(
@@ -70,10 +69,10 @@ public function testGenerateMkCalendarBody()
public function testGenerateProfindBody()
{
$this->generator
->shouldReceive('propfindBody')
->once()
->expects($this->once())
->method('propfindBody')
->with(self::$property_list)
->andReturn('result');
->willReturn('result');
$toolkit = $this->createToolkit();
$this->assertEquals(
@@ -85,10 +84,10 @@ public function testGenerateProfindBody()
public function testGenerateProppatchBody()
{
$this->generator
->shouldReceive('proppatchBody')
->once()
->expects($this->once())
->method('proppatchBody')
->with(self::$property_list)
->andReturn('result');
->willReturn('result');
$toolkit = $this->createToolkit();
$this->assertEquals(
@@ -99,12 +98,12 @@ public function testGenerateProppatchBody()
public function testGenerateCalendarQueryReportBody()
{
$filter = m::mock('AgenDAV\CalDAV\ComponentFilter');
$filter = $this->createMock(\AgenDAV\CalDAV\ComponentFilter::class);
$this->generator
->shouldReceive('calendarQueryBody')
->once()
->expects($this->once())
->method('calendarQueryBody')
->with($filter)
->andReturn('result');
->willReturn('result');
$toolkit = $this->createToolkit();
$this->assertEquals(
@@ -115,12 +114,11 @@ public function testGenerateCalendarQueryReportBody()
public function testGeneratePrincipalPropertySearchReportBody()
{
$filter = m::mock('AgenDAV\CalDAV\Filter\PrincipalPropertySearch');
$filter = $this->createMock(\AgenDAV\CalDAV\Filter\PrincipalPropertySearch::class);
$this->generator
->shouldReceive('principalPropertySearchBody')
->once()
->method('principalPropertySearchBody')
->with($filter)
->andReturn('result');
->willReturn('result');
$toolkit = $this->createToolkit();
$this->assertEquals(
@@ -8,9 +8,6 @@
<testsuite name="AgenDAV">
<directory>AgenDAV/</directory>
</testsuite>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener"></listener>
</listeners>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory>../web/src/</directory>
@@ -35,7 +35,6 @@
},

"require-dev": {
"mockery/mockery": "~0.9.1",
"phpunit/phpunit": "~5.7.0"
},
"autoload": {

0 comments on commit fe86b7d

Please sign in to comment.
You can’t perform that action at this time.