Skip to content
On this page

PHP

Version

Running Php on Php v8.1.27

Supported languages

PHP

Testing framework

phpunit

Special reminders and implementation details

ts
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class StackTest extends TestCase
{
    public function testPushAndPop(): void
    {
        $stack = [];
        $this->assertSame(0, count($stack));

        array_push($stack, 'foo');
        $this->assertSame('foo', $stack[count($stack)-1]);
        $this->assertSame(1, count($stack));

        $this->assertSame('foo', array_pop($stack));
        $this->assertSame(0, count($stack));
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18