21 lines
490 B
PHP
21 lines
490 B
PHP
<?php
|
|
declare(strict_types = 1);
|
|
|
|
/**
|
|
* phpunit 实例
|
|
*/
|
|
class StackTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
public function testPushAndPop() : void
|
|
{
|
|
$stack = [];
|
|
$this->assertSame(0, count($stack));
|
|
|
|
$stack[] = 'fooq';
|
|
$this->assertSame('fooq', $stack[ count($stack) - 1 ]);
|
|
$this->assertSame(1, count($stack));
|
|
|
|
$this->assertSame('fooq', array_pop($stack));
|
|
$this->assertSame(0, count($stack));
|
|
}
|
|
} |