CellCollectionTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. use Maatwebsite\Excel\Collections\CellCollection;
  3. class CellCollectionTest extends TestCase {
  4. public function __construct()
  5. {
  6. $this->collection = new CellCollection([
  7. 'one' => 'one',
  8. 'two' => 'two'
  9. ]);
  10. }
  11. public function testSetItems()
  12. {
  13. $this->collection->setItems([
  14. 'three' => 'three'
  15. ]);
  16. $this->assertContains('three', $this->collection);
  17. $this->assertCount(3, $this->collection);
  18. }
  19. public function testDynamicGetters()
  20. {
  21. $this->assertEquals('two', $this->collection->two);
  22. }
  23. public function testIsset()
  24. {
  25. $this->assertTrue(isset($this->collection->two));
  26. $this->assertFalse(isset($this->collection->nonexisting));
  27. }
  28. public function testEmpty()
  29. {
  30. $this->assertFalse(empty($this->collection->two));
  31. $this->assertTrue(empty($this->collection->nonexisting));
  32. }
  33. public function testDynamicCheck()
  34. {
  35. $this->assertTrue($this->collection->two ? true : false);
  36. $this->assertFalse($this->collection->nonexisting ? true : false);
  37. }
  38. }