コード例 #1
0
 public function testError()
 {
     $this->assertEmpty($this->flash->getAllError());
     $this->assertNull($this->flash->getError("foo"));
     $this->assertEquals("bar", $this->flash->getError("foo", "bar"));
     $this->assertFalse($this->flash->hasAnyError());
     $this->flash->setError("foo", "bar");
     $this->flash = new FlashMessages($this->storage, $this->key);
     $this->assertEquals(["foo" => "bar"], $this->flash->getAllError());
     $this->assertEquals("bar", $this->flash->getError("foo"));
     $this->assertTrue($this->flash->hasAnyError());
     $this->flash->setError("foo", "bar");
     $this->flash->setError("foo2", "bar2");
     $this->assertArrayHasKey("error", $this->storage[$this->key]);
     $this->assertEquals("bar", $this->storage[$this->key]["error"]["foo"]);
     $this->flash->removeError("foo");
     $this->assertArrayNotHasKey("foo", $this->storage[$this->key]["error"]);
     $this->assertNotEmpty($this->storage[$this->key]["error"]);
     $this->flash->removeAllError();
     $this->assertEmpty($this->storage[$this->key]["error"]);
 }