コード例 #1
0
ファイル: GalleryItemCreator.php プロジェクト: CiNiK/lisar
 public function delete(GalleryItem $item)
 {
     $props = $item->toArray();
     if (file_exists(ROOT . $props['fullsrc'])) {
         unlink(ROOT . $props['fullsrc']);
     }
     if (file_exists(ROOT . $props['lowsrc'])) {
         unlink(ROOT . $props['lowsrc']);
     }
 }
コード例 #2
0
ファイル: GalleryListTest.php プロジェクト: CiNiK/lisar
 public function testDeleteFromFile()
 {
     $list = new Gallery();
     $list->fromJson(self::$outputDir . self::$jsonName);
     $item = new GalleryItem("desc", "year", "pathToFull", "pathToThumb");
     $this->assertTrue($list->exists($item->getName()));
     $this->assertTrue($list->deleteByName($item->getName()));
     $this->assertFalse($list->exists($item->getName()));
     $list = new Gallery();
     $list->fromJson(self::$outputDir . self::$jsonName);
     $this->assertFalse($list->exists($item->getName()));
 }
コード例 #3
0
ファイル: Gallery.php プロジェクト: CiNiK/lisar
 public function add(GalleryItem $image)
 {
     $this->items[] = $image->toArray();
     $this->save();
 }
コード例 #4
0
ファイル: GalleryItemTest.php プロジェクト: CiNiK/lisar
 public function testToArray()
 {
     $item = new GalleryItem('img', '2016', 'pathToFull', 'pathToLow');
     $this->assertEquals($item->toArray(), ['description' => 'img', 'category' => '2016', 'fullsrc' => 'pathToFull', 'lowsrc' => 'pathToLow']);
 }