CollectionTest.php 731 B

12345678910111213141516171819202122232425262728293031
  1. <?php declare(strict_types=1);
  2. /**
  3. * This file is part of toolkit/stdlib.
  4. *
  5. * @author https://github.com/inhere
  6. * @link https://github.com/php-toolkit/stdlib
  7. * @license MIT
  8. */
  9. namespace Toolkit\StdlibTest\Std;
  10. use Toolkit\Stdlib\Std\Collection;
  11. use Toolkit\StdlibTest\BaseLibTestCase;
  12. /**
  13. * class CollectionTest
  14. *
  15. * @author inhere
  16. */
  17. class CollectionTest extends BaseLibTestCase
  18. {
  19. public function testCollection_basic(): void
  20. {
  21. $c = Collection::new(['age' => 23, 'name' => 'inhere']);
  22. $this->assertTrue($c->has('age'));
  23. $this->assertEquals(23, $c->get('age'));
  24. $this->assertEquals(23, $c->getInt('age'));
  25. $this->assertEquals('23', $c->getString('age'));
  26. }
  27. }