Skip to content

Commit

Permalink
Fix phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
mducharme committed Jul 24, 2019
1 parent 353187b commit 94f7a57
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 105 deletions.
4 changes: 2 additions & 2 deletions tests/Charcoal/Object/CategoryTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testUnsetCategoryItemTypeThrowsException()
$mock = $this->createTrait();

$this->expectException('\Exception');
$mock->categoryItemType();
$mock->getCategoryItemType();
}

/**
Expand All @@ -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);
Expand Down
64 changes: 32 additions & 32 deletions tests/Charcoal/Object/ContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand All @@ -79,32 +79,32 @@ 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']);
}

/**
* @return void
*/
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']);
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Charcoal/Object/HierarchicalTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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());
}
Expand Down
58 changes: 29 additions & 29 deletions tests/Charcoal/Object/ObjectRevisionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -62,26 +62,26 @@ 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']);
}

/**
* @return void
*/
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([]);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -126,41 +126,41 @@ 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']);
}

/**
* @return void
*/
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']);
}

/**
* @return void
*/
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']);
}

/**
Expand Down
Loading

0 comments on commit 94f7a57

Please sign in to comment.