From 94f7a5709c89a97e8d77dd4711422ad0ec647693 Mon Sep 17 00:00:00 2001 From: Mathieu Ducharme Date: Wed, 24 Jul 2019 10:35:06 -0400 Subject: [PATCH] Fix phpunit --- tests/Charcoal/Object/CategoryTraitTest.php | 4 +- tests/Charcoal/Object/ContentTest.php | 64 +++++++++---------- .../Charcoal/Object/HierarchicalTraitTest.php | 4 +- tests/Charcoal/Object/ObjectRevisionTest.php | 58 ++++++++--------- tests/Charcoal/Object/ObjectRouteTest.php | 30 ++++----- .../Charcoal/Object/PublishableTraitTest.php | 24 +++---- tests/Charcoal/Object/RoutableTraitTest.php | 6 +- tests/Charcoal/Object/UserDataTest.php | 20 +++--- 8 files changed, 105 insertions(+), 105 deletions(-) diff --git a/tests/Charcoal/Object/CategoryTraitTest.php b/tests/Charcoal/Object/CategoryTraitTest.php index ea2f5f0..e065e70 100644 --- a/tests/Charcoal/Object/CategoryTraitTest.php +++ b/tests/Charcoal/Object/CategoryTraitTest.php @@ -30,7 +30,7 @@ public function testUnsetCategoryItemTypeThrowsException() $mock = $this->createTrait(); $this->expectException('\Exception'); - $mock->categoryItemType(); + $mock->getCategoryItemType(); } /** @@ -42,7 +42,7 @@ public function testSetCategoryItemType() $ret = $mock->setCategoryItemType('foobar'); $this->assertSame($ret, $mock); - $this->assertEquals('foobar', $mock->categoryItemType()); + $this->assertEquals('foobar', $mock->getCategoryItemType()); $this->expectException('\InvalidArgumentException'); $mock->setCategoryItemType(false); diff --git a/tests/Charcoal/Object/ContentTest.php b/tests/Charcoal/Object/ContentTest.php index f3dcb9a..a30bb8d 100644 --- a/tests/Charcoal/Object/ContentTest.php +++ b/tests/Charcoal/Object/ContentTest.php @@ -48,20 +48,20 @@ public function setUp() */ public function testDefaults() { - $this->assertTrue($this->obj->active()); - $this->assertEquals(0, $this->obj->position()); - $this->assertEquals([], $this->obj->requiredAclPermissions()); + $this->assertTrue($this->obj['active']); + $this->assertEquals(0, $this->obj['position']); + $this->assertEquals([], $this->obj['requiredAclPermissions']); // Timestampable properties - $this->assertNull($this->obj->created()); - $this->assertNull($this->obj->lastModified()); + $this->assertNull($this->obj['created']); + $this->assertNull($this->obj['lastModified']); // Authorable properties - $this->assertNull($this->obj->createdBy()); - $this->assertNull($this->obj->lastModifiedBy()); + $this->assertNull($this->obj['createdBy']); + $this->assertNull($this->obj['lastModifiedBy']); // Revisionable properties - $this->assertTrue($this->obj->revisionEnabled()); + $this->assertTrue($this->obj['revisionEnabled']); } /** @@ -79,15 +79,15 @@ public function testSetData() 'required_acl_permissions' => ['foo', 'bar'] ]); $this->assertSame($ret, $this->obj); - $this->assertNotTrue($this->obj->active()); - $this->assertEquals(42, $this->obj->position()); + $this->assertNotTrue($this->obj['active']); + $this->assertEquals(42, $this->obj['position']); $expected = new DateTime('2015-01-01 13:05:45'); - $this->assertEquals($expected, $this->obj->created()); - $this->assertEquals('Me', $this->obj->createdBy()); + $this->assertEquals($expected, $this->obj['created']); + $this->assertEquals('Me', $this->obj['createdBy']); $expected = new DateTime('2015-04-01 22:10:30'); - $this->assertEquals($expected, $this->obj->lastModified()); - $this->assertEquals('You', $this->obj->lastModifiedBy()); - $this->assertEquals(['foo', 'bar'], $this->obj->requiredAclPermissions()); + $this->assertEquals($expected, $this->obj['lastModified']); + $this->assertEquals('You', $this->obj['lastModifiedBy']); + $this->assertEquals(['foo', 'bar'], $this->obj['requiredAclPermissions']); } /** @@ -95,16 +95,16 @@ public function testSetData() */ public function testSetActive() { - $this->assertTrue($this->obj->active()); + $this->assertTrue($this->obj['active']); $ret = $this->obj->setActive(false); $this->assertSame($ret, $this->obj); - $this->assertFalse($this->obj->active()); + $this->assertFalse($this->obj['active']); $this->obj->setActive(1); - $this->assertTrue($this->obj->active()); + $this->assertTrue($this->obj['active']); $this->obj['active'] = false; - $this->assertFalse($this->obj->active()); + $this->assertFalse($this->obj['active']); $this->obj->set('active', true); $this->assertTrue($this->obj['active']); @@ -116,19 +116,19 @@ public function testSetActive() public function testSetPosition() { $this->obj = $this->obj; - $this->assertEquals(0, $this->obj->position()); + $this->assertEquals(0, $this->obj['position']); $ret = $this->obj->setPosition(42); $this->assertSame($ret, $this->obj); - $this->assertEquals(42, $this->obj->position()); + $this->assertEquals(42, $this->obj['position']); $this->obj['position'] = '3'; - $this->assertEquals(3, $this->obj->position()); + $this->assertEquals(3, $this->obj['position']); $this->obj->set('position', 1); $this->assertEquals(1, $this->obj['position']); $this->obj->setPosition(null); - $this->assertEquals(0, $this->obj->position()); + $this->assertEquals(0, $this->obj['position']); $this->expectException(\InvalidArgumentException::class); $this->obj->setPosition('foo'); @@ -142,11 +142,11 @@ public function testSetCreated() $ret = $this->obj->setCreated('2015-01-01 13:05:45'); $this->assertSame($ret, $this->obj); $expected = new DateTime('2015-01-01 13:05:45'); - $this->assertEquals($expected, $this->obj->created()); + $this->assertEquals($expected, $this->obj['created']); $this->obj['created'] = 'today'; $expected = new DateTime('today'); - $this->assertEquals($expected, $this->obj->created()); + $this->assertEquals($expected, $this->obj['created']); $this->obj->set('created', 'tomorrow'); $expected = new DateTime('tomorrow'); @@ -172,7 +172,7 @@ public function testSetCreatedBy() { $ret = $this->obj->setCreatedBy('Me'); $this->assertSame($ret, $this->obj); - $this->assertEquals('Me', $this->obj->createdBy()); + $this->assertEquals('Me', $this->obj['createdBy']); //$this->expectException(\InvalidArgumentException::class); //$this->obj->setCreatedBy(false); @@ -186,11 +186,11 @@ public function testSetLastModified() $ret = $this->obj->setLastModified('2015-01-01 13:05:45'); $this->assertSame($ret, $this->obj); $expected = new DateTime('2015-01-01 13:05:45'); - $this->assertEquals($expected, $this->obj->lastModified()); + $this->assertEquals($expected, $this->obj['lastModified']); $this->obj['last_modified'] = 'today'; $expected = new DateTime('today'); - $this->assertEquals($expected, $this->obj->lastModified()); + $this->assertEquals($expected, $this->obj['lastModified']); $this->obj->set('last_modified', 'tomorrow'); $expected = new DateTime('tomorrow'); @@ -216,7 +216,7 @@ public function testSetLastModifiedBy() { $ret = $this->obj->setLastModifiedBy('Me'); $this->assertSame($ret, $this->obj); - $this->assertEquals('Me', $this->obj->lastModifiedBy()); + $this->assertEquals('Me', $this->obj['lastModifiedBy']); //$this->expectException(\InvalidArgumentException::class); //$this->obj->setLastModifiedBy(false); @@ -233,13 +233,13 @@ public function testSetRequiredAclPermissions() $this->assertEquals(['a', 'b', 'c'], $this->obj['required_acl_permissions']); $this->obj->setRequiredAclPermissions('foo, bar'); - $this->assertEquals(['foo', 'bar'], $this->obj->requiredAclPermissions()); + $this->assertEquals(['foo', 'bar'], $this->obj['requiredAclPermissions']); $this->obj->setRequiredAclPermissions(null); - $this->assertEquals([], $this->obj->requiredAclPermissions()); + $this->assertEquals([], $this->obj['requiredAclPermissions']); $this->obj->setRequiredAclPermissions(false); - $this->assertEquals([], $this->obj->requiredAclPermissions()); + $this->assertEquals([], $this->obj['requiredAclPermissions']); $this->expectException(\InvalidArgumentException::class); $this->obj->setRequiredAclPermissions(true); diff --git a/tests/Charcoal/Object/HierarchicalTraitTest.php b/tests/Charcoal/Object/HierarchicalTraitTest.php index 3474e51..c948cf7 100644 --- a/tests/Charcoal/Object/HierarchicalTraitTest.php +++ b/tests/Charcoal/Object/HierarchicalTraitTest.php @@ -39,7 +39,7 @@ public function testSetMaster() $master = $this->createMock(get_class($obj)); $ret = $obj->setMaster($master); $this->assertSame($ret, $obj); - $this->assertSame($master, $obj->master()); + $this->assertSame($master, $obj->getMaster()); $this->expectException('\InvalidArgumentException'); $obj->setMaster(['foobar']); @@ -99,7 +99,7 @@ public function testHierarchyLevel() $this->assertEquals(2, $obj->hierarchyLevel()); $master2 = $this->createMock(get_class($obj)); - $obj->master()->setMaster($master2); + $obj->getMaster()->setMaster($master2); //$this->assertEquals(3, $obj->hierarchyLevel()); } diff --git a/tests/Charcoal/Object/ObjectRevisionTest.php b/tests/Charcoal/Object/ObjectRevisionTest.php index 82390c6..851cfe2 100644 --- a/tests/Charcoal/Object/ObjectRevisionTest.php +++ b/tests/Charcoal/Object/ObjectRevisionTest.php @@ -48,12 +48,12 @@ public function setUp() */ public function testSetObjType() { - $this->assertNull($this->obj->targetType()); + $this->assertNull($this->obj['targetType']); $ret = $this->obj->setTargetType('foobar'); $this->assertSame($ret, $this->obj); - $this->assertEquals('foobar', $this->obj->targetType()); + $this->assertEquals('foobar', $this->obj['targetType']); - $this->expectException('\InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->obj->setTargetType(false); } @@ -62,10 +62,10 @@ public function testSetObjType() */ public function testSetObjId() { - $this->assertNull($this->obj->targetId()); + $this->assertNull($this->obj['targetId']); $ret = $this->obj->setTargetId(42); $this->assertSame($ret, $this->obj); - $this->assertEquals(42, $this->obj->targetId()); + $this->assertEquals(42, $this->obj['targetId']); } /** @@ -73,15 +73,15 @@ public function testSetObjId() */ public function testSetRevNum() { - $this->assertNull($this->obj->revNum()); + $this->assertNull($this->obj['revNum']); $ret = $this->obj->setRevNum(66); $this->assertSame($ret, $this->obj); - $this->assertEquals(66, $this->obj->revNum()); + $this->assertEquals(66, $this->obj['revNum']); $this->obj->setRevNum('42'); - $this->assertEquals(42, $this->obj->revNum()); + $this->assertEquals(42, $this->obj['revNum']); - $this->expectException('\InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->obj->setRevNum([]); } @@ -91,16 +91,16 @@ public function testSetRevNum() public function testSetRevTs() { $obj = $this->obj; - $this->assertNull($obj->revTs()); + $this->assertNull($obj['revTs']); $ret = $obj->setRevTs('2015-01-01 13:05:45'); $this->assertSame($ret, $obj); $expected = new DateTime('2015-01-01 13:05:45'); - $this->assertEquals($expected, $obj->revTs()); + $this->assertEquals($expected, $obj['revTs']); $obj->setRevTs(null); - $this->assertNull($obj->revTs()); + $this->assertNull($obj['revTs']); - $this->expectException('\InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $obj->setRevTs(false); } @@ -109,15 +109,15 @@ public function testSetRevTs() */ public function testSetRevUser() { - $this->assertNull($this->obj->revUser()); + $this->assertNull($this->obj['revUser']); $ret = $this->obj->setRevUser('me'); $this->assertSame($ret, $this->obj); - $this->assertEquals('me', $this->obj->revUser()); + $this->assertEquals('me', $this->obj['revUser']); $this->obj->setRevUser(null); - $this->assertNull($this->obj->revUser()); + $this->assertNull($this->obj['revUser']); - $this->expectException('\InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->obj->setRevUser(false); } @@ -126,13 +126,13 @@ public function testSetRevUser() */ public function testSetDataPrev() { - $this->assertNull($this->obj->dataPrev()); + $this->assertNull($this->obj['dataPrev']); $ret = $this->obj->setDataPrev(['foo'=>1]); $this->assertSame($ret, $this->obj); - $this->assertEquals(['foo'=>1], $this->obj->dataPrev()); + $this->assertEquals(['foo'=>1], $this->obj['dataPrev']); - $this->assertEquals(['bar'], $this->obj->setDataPrev('["bar"]')->dataPrev()); - $this->assertEquals([], $this->obj->setDataPrev(null)->dataPrev()); + $this->assertEquals(['bar'], $this->obj->setDataPrev('["bar"]')['dataPrev']); + $this->assertEquals([], $this->obj->setDataPrev(null)['dataPrev']); } /** @@ -140,13 +140,13 @@ public function testSetDataPrev() */ public function testSetDataObj() { - $this->assertNull($this->obj->dataObj()); + $this->assertNull($this->obj['dataObj']); $ret = $this->obj->setDataObj(['foo'=>1]); $this->assertSame($ret, $this->obj); - $this->assertEquals(['foo'=>1], $this->obj->dataObj()); + $this->assertEquals(['foo'=>1], $this->obj['dataObj']); - $this->assertEquals(['bar'], $this->obj->setDataObj('["bar"]')->dataObj()); - $this->assertEquals([], $this->obj->setDataObj(null)->dataObj()); + $this->assertEquals(['bar'], $this->obj->setDataObj('["bar"]')['dataObj']); + $this->assertEquals([], $this->obj->setDataObj(null)['dataObj']); } /** @@ -154,13 +154,13 @@ public function testSetDataObj() */ public function testSetDataDiff() { - $this->assertNull($this->obj->dataDiff()); + $this->assertNull($this->obj['dataDiff']); $ret = $this->obj->setDataDiff(['foo'=>1]); $this->assertSame($ret, $this->obj); - $this->assertEquals(['foo'=>1], $this->obj->dataDiff()); + $this->assertEquals(['foo'=>1], $this->obj['dataDiff']); - $this->assertEquals(['bar'], $this->obj->setDataDiff('["bar"]')->dataDiff()); - $this->assertEquals([], $this->obj->setDataDiff(null)->dataDiff()); + $this->assertEquals(['bar'], $this->obj->setDataDiff('["bar"]')['dataDiff']); + $this->assertEquals([], $this->obj->setDataDiff(null)['dataDiff']); } /** diff --git a/tests/Charcoal/Object/ObjectRouteTest.php b/tests/Charcoal/Object/ObjectRouteTest.php index 6a97717..e0c0bad 100644 --- a/tests/Charcoal/Object/ObjectRouteTest.php +++ b/tests/Charcoal/Object/ObjectRouteTest.php @@ -48,7 +48,7 @@ public function setUp() */ public function testDefaults() { - $this->assertNull($this->obj->id()); + $this->assertNull($this->obj['id']); } /** @@ -58,7 +58,7 @@ public function testSetData() { $ret = $this->obj->setData([ 'id' => 42, - 'creation_date' => 'today', + 'creationDate' => 'today', 'last_modification_date' => 'today', 'lang' => 'es', 'slug' => 'foobar', @@ -69,14 +69,14 @@ public function testSetData() $this->assertSame($ret, $this->obj); - $this->assertEquals(42, $this->obj->id()); + $this->assertEquals(42, $this->obj['id']); $expected = new DateTime('today'); - $this->assertEquals($expected, $this->obj->creationDate()); - $this->assertEquals($expected, $this->obj->lastModificationDate()); + $this->assertEquals($expected, $this->obj['creationDate']); + $this->assertEquals($expected, $this->obj['lastModificationDate']); - $this->assertEquals('es', $this->obj->lang()); - $this->assertEquals('foobar', $this->obj->slug()); + $this->assertEquals('es', $this->obj['lang']); + $this->assertEquals('foobar', $this->obj['slug']); $this->assertEquals('foo', $this->obj->routeObjType()); $this->assertEquals(3, $this->obj->routeObjId()); $this->assertEquals('baz', $this->obj->routeTemplate()); @@ -89,10 +89,10 @@ public function testSetId() { $ret = $this->obj->setId(3); $this->assertSame($ret, $this->obj); - $this->assertEquals(3, $this->obj->id()); + $this->assertEquals(3, $this->obj['id']); $this->obj['id'] = 42; - $this->assertEquals(42, $this->obj->id()); + $this->assertEquals(42, $this->obj['id']); $this->obj->set('id', 10); $this->assertEquals(10, $this->obj['id']); @@ -103,7 +103,7 @@ public function testSetId() */ public function testSetCreationDate() { - $this->assertNull($this->obj->creationDate()); + $this->assertNull($this->obj['creationDate']); } /** @@ -125,19 +125,19 @@ public function testLang() */ public function testSetSlug() { - $this->assertNull($this->obj->slug()); + $this->assertNull($this->obj['slug']); $ret = $this->obj->setSlug('foo'); $this->assertSame($ret, $this->obj); - $this->assertEquals('foo', $this->obj->slug()); + $this->assertEquals('foo', $this->obj['slug']); $this->obj['slug'] = 'foobar'; - $this->assertEquals('foobar', $this->obj->slug()); + $this->assertEquals('foobar', $this->obj['slug']); $this->obj->set('slug', 'bar'); - $this->assertEquals('bar', $this->obj->slug()); + $this->assertEquals('bar', $this->obj['slug']); $this->obj['slug'] = null; - $this->assertNull($this->obj->slug()); + $this->assertNull($this->obj['slug']); $this->expectException('\InvalidArgumentException'); $this->obj->setSlug(false); diff --git a/tests/Charcoal/Object/PublishableTraitTest.php b/tests/Charcoal/Object/PublishableTraitTest.php index a76a8b5..2bfea10 100644 --- a/tests/Charcoal/Object/PublishableTraitTest.php +++ b/tests/Charcoal/Object/PublishableTraitTest.php @@ -66,13 +66,13 @@ public function testPublishDate() $ret = $obj->setPublishDate('2015-01-01 00:00:00'); $this->assertSame($ret, $obj); - $this->assertEquals($time, $obj->publishDate()); + $this->assertEquals($time, $obj->getPublishDate()); $obj->setPublishDate(''); - $this->assertNull($obj->publishDate()); + $this->assertNull($obj->getPublishDate()); $obj->setPublishDate($time); - $this->assertEquals($time, $obj->publishDate()); + $this->assertEquals($time, $obj->getPublishDate()); } /** @@ -113,13 +113,13 @@ public function testExpiryDate() $ret = $obj->setExpiryDate('2015-01-01 00:00:00'); $this->assertSame($ret, $obj); - $this->assertEquals($time, $obj->expiryDate()); + $this->assertEquals($time, $obj->getExpiryDate()); $obj->setExpiryDate(''); - $this->assertNull($obj->expiryDate()); + $this->assertNull($obj->getExpiryDate()); $obj->setExpiryDate($time); - $this->assertEquals($time, $obj->expiryDate()); + $this->assertEquals($time, $obj->getExpiryDate()); } /** @@ -152,22 +152,22 @@ public function testPublishStatus() $obj = $this->obj; $obj->setPublishStatus(Publishable::STATUS_DRAFT); - $this->assertEquals(Publishable::STATUS_DRAFT, $obj->publishStatus()); + $this->assertEquals(Publishable::STATUS_DRAFT, $obj->getPublishStatus()); $obj->setPublishStatus(Publishable::STATUS_PENDING); - $this->assertEquals(Publishable::STATUS_PENDING, $obj->publishStatus()); + $this->assertEquals(Publishable::STATUS_PENDING, $obj->getPublishStatus()); $obj->setPublishStatus(Publishable::STATUS_PUBLISHED); - $this->assertEquals(Publishable::STATUS_PUBLISHED, $obj->publishStatus()); + $this->assertEquals(Publishable::STATUS_PUBLISHED, $obj->getPublishStatus()); $obj->setPublishStatus(Publishable::STATUS_UPCOMING); - $this->assertEquals(Publishable::STATUS_PUBLISHED, $obj->publishStatus()); + $this->assertEquals(Publishable::STATUS_PUBLISHED, $obj->getPublishStatus()); $obj->setPublishStatus(Publishable::STATUS_EXPIRED); - $this->assertEquals(Publishable::STATUS_PUBLISHED, $obj->publishStatus()); + $this->assertEquals(Publishable::STATUS_PUBLISHED, $obj->getPublishStatus()); $obj->setPublishStatus(''); - $this->assertNull($obj->publishStatus()); + $this->assertNull($obj->getPublishStatus()); $this->expectException(InvalidArgumentException::class); $obj->setPublishStatus('foobar'); diff --git a/tests/Charcoal/Object/RoutableTraitTest.php b/tests/Charcoal/Object/RoutableTraitTest.php index 18e90b1..b389c68 100644 --- a/tests/Charcoal/Object/RoutableTraitTest.php +++ b/tests/Charcoal/Object/RoutableTraitTest.php @@ -170,14 +170,14 @@ public function testIsSlugEditable() */ public function testSlug() { - $this->assertNull($this->obj->slug()); + $this->assertNull($this->obj->getSlug()); $ret = $this->obj->setSlug('test123'); $this->assertSame($ret, $this->obj); - $this->assertEquals('test123', $this->obj->slug()); + $this->assertEquals('test123', $this->obj->getSlug()); $this->obj->setSlug(null); - $this->assertNull($this->obj->slug()); + $this->assertNull($this->obj->getSlug()); } /** diff --git a/tests/Charcoal/Object/UserDataTest.php b/tests/Charcoal/Object/UserDataTest.php index 82a7000..2e6038c 100644 --- a/tests/Charcoal/Object/UserDataTest.php +++ b/tests/Charcoal/Object/UserDataTest.php @@ -48,9 +48,9 @@ public function setUp() */ public function testDefaults() { - $this->assertNull($this->obj->ip()); - $this->assertNull($this->obj->lang()); - $this->assertNull($this->obj->ts()); + $this->assertNull($this->obj['ip']); + $this->assertNull($this->obj['lang']); + $this->assertNull($this->obj['ts']); } /** @@ -64,10 +64,10 @@ public function testSetData() 'ts'=>'2015-01-01 15:05:20' ]); $this->assertSame($ret, $this->obj); - $this->assertEquals(ip2long('192.168.1.1'), $this->obj->ip()); - $this->assertEquals('fr', $this->obj->lang()); + $this->assertEquals(ip2long('192.168.1.1'), $this->obj['ip']); + $this->assertEquals('fr', $this->obj['lang']); $expected = new DateTime('2015-01-01 15:05:20'); - $this->assertEquals($expected, $this->obj->ts()); + $this->assertEquals($expected, $this->obj['ts']); } /** @@ -78,10 +78,10 @@ public function testSetIp() $this->obj = $this->obj; $ret = $this->obj->setIp('1.1.1.1'); $this->assertSame($ret, $this->obj); - $this->assertEquals(ip2long('1.1.1.1'), $this->obj->ip()); + $this->assertEquals(ip2long('1.1.1.1'), $this->obj['ip']); $this->obj->setIp(2349255); - $this->assertEquals(2349255, $this->obj->ip()); + $this->assertEquals(2349255, $this->obj['ip']); } /** @@ -92,7 +92,7 @@ public function testSetLang() $this->obj = $this->obj; $ret = $this->obj->setLang('en'); $this->assertSame($ret, $this->obj); - $this->assertEquals('en', $this->obj->lang()); + $this->assertEquals('en', $this->obj['lang']); $this->expectException('\InvalidArgumentException'); $this->obj->setLang(false); @@ -107,7 +107,7 @@ public function testSetTs() $ret = $this->obj->setTs('July 1st, 2014'); $this->assertSame($ret, $this->obj); $expected = new DateTime('July 1st, 2014'); - $this->assertEquals($expected, $this->obj->ts()); + $this->assertEquals($expected, $this->obj['ts']); $this->expectException('\InvalidArgumentException'); $this->obj->setTs(false);