Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $model = new TestDocument();
     $model->createDatabaseTable(true);
     Helper::dbFixture(SITEMAP_TABLE, []);
     \ACL::create(SitemapModel::PermissionName);
     Configure::write('Sitemap', ['Menu' => ['title' => self::Title, 'depth' => 3]]);
     Helper::setupUsers([['login' => self::AdminUser, 'rights' => [SitemapModel::PermissionName => true]], ['login' => self::GuestUser]]);
     $documents = [['name' => 'first', 'sitemap' => ['count' => 1]], ['name' => 'second'], ['name' => 'third', 'sitemap' => ['parent' => 1]]];
     foreach ($documents as $key => $row) {
         $documents[$key] = new TestDocument($row);
         $documents[$key]->insert();
         $sitemapModel = new SitemapModel();
         $sitemapModel->name = $row['name'];
         $sitemapModel->full_url = $row['name'];
         $sitemapModel->linkToModel($documents[$key]);
         if (isset($row['sitemap'])) {
             foreach ($row['sitemap'] as $key => $value) {
                 $sitemapModel->{$key} = $value;
             }
         }
         $sitemapModel->insert();
     }
 }
Exemplo n.º 2
0
 /**
  * Тестируем каскадное удаление
  */
 public function testRecursiveRemoving()
 {
     $document = new TestDocument();
     $document->name = 'Test inserting';
     $document->insert();
     $nRoot = Sitemap::addPage('Test inserting', 'xx', TestDocument::ModelName, 1, 0);
     $document = new TestDocument();
     $document->name = 'Test inserting2';
     $document->insert();
     Sitemap::addPage('Test inserting2', 'xx', TestDocument::ModelName, 2, $nRoot);
     //
     Sitemap::removeDocument(TestDocument::ModelName, '1');
     // Проверяем удаление из бд
     $result = DB::get(sprintf('SELECT COUNT(*) as `count` FROM `%s`', TestDocument::TableName));
     $this->assertEquals($result['count'], 0);
 }