Skip to content

Commit

Permalink
added more tests for the CollectionFactory class
Browse files Browse the repository at this point in the history
  • Loading branch information
walkersoft committed May 23, 2018
1 parent 2eb338b commit c0ccca1
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/CollectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ public function testCreatingNewEmptyCollection()
$this->assertInstanceOf(Collection::class, $collection);
}

public function testCreatingNewCollectionWithItems()
{
$collection = CollectionFactory::newCollection(
[
'foo',
'bar'
]
);

$this->assertEquals(2, count($collection));
$this->assertInstanceOf(Collection::class, $collection);
}

public function testCreatingNewEmptyTypedCollection()
{
$collection = CollectionFactory::newTypedCollection(CrashTestDummy::class);
Expand All @@ -33,6 +46,20 @@ public function testCreatingNewEmptyTypedCollection()
$this->assertInstanceOf(TypedCollection::class, $collection);
}

public function testCreatingNewTypedCollectionWithItems()
{
$collection = CollectionFactory::newTypedCollection(
CrashTestDummy::class,
[
new CrashTestDummy(),
new CrashTestDummy()
]
);

$this->assertEquals(2, count($collection));
$this->assertInstanceOf(Collection::class, $collection);
}

public function testCreatingNewEmptyDictionary()
{
$dictionary = CollectionFactory::newDictionary();
Expand All @@ -41,11 +68,38 @@ public function testCreatingNewEmptyDictionary()
$this->assertInstanceOf(Dictionary::class, $dictionary);
}

public function testCreatingDictionaryWithItems()
{
$dictionary = CollectionFactory::newDictionary(
[
'foo' => 'bar',
'baz' => 'qux'
]
);

$this->assertEquals(2, count($dictionary));
$this->assertInstanceOf(Dictionary::class, $dictionary);
}

public function testCreatingNewEmptyTypedDictionary()
{
$dictionary = CollectionFactory::newTypedDictionary(CrashTestDummy::class);

$this->assertEquals(0, count($dictionary));
$this->assertInstanceOf(TypedDictionary::class, $dictionary);
}

public function testCreatingTypedDictionaryWithItems()
{
$dictionary = CollectionFactory::newTypedDictionary(
CrashTestDummy::class,
[
'foo' => new CrashTestDummy(),
'bar' => new CrashTestDummy()
]
);

$this->assertEquals(2, count($dictionary));
$this->assertInstanceOf(Dictionary::class, $dictionary);
}
}

0 comments on commit c0ccca1

Please sign in to comment.