コード例 #1
0
ファイル: InMemoryTest.php プロジェクト: cyrixhero/Elgg
 public function testPutOverridesGetCallback()
 {
     $pool = new InMemory();
     $result = $pool->get('foo', function () {
         return 1;
     });
     $this->assertEquals(1, $result);
     $pool->put('foo', 2);
     $result = $pool->get('foo', function () {
         return 3;
     });
     $this->assertEquals(2, $result);
 }
コード例 #2
0
ファイル: InMemoryTest.php プロジェクト: elgg/elgg
 public function testIsMappable()
 {
     $collection = InMemory::fromArray([0, 1, 2, 3, 4]);
     $mapped = $collection->map(function ($number) {
         return $number * 2;
     });
     $this->assertTrue($mapped->contains(0));
     $this->assertTrue($mapped->contains(2));
     $this->assertTrue($mapped->contains(4));
     $this->assertTrue($mapped->contains(6));
     $this->assertTrue($mapped->contains(8));
     $this->assertEquals(5, count($mapped));
     $this->assertNotSame($mapped, $collection);
 }