Skip to content
Snippets Groups Projects
Pcdm4BrowserTest.php 2.67 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
 *
 * BOKEH is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation.
 *
 * There are special exceptions to the terms and conditions of the AGPL as it
 * is applied to this software (see README file).
 *
 * BOKEH is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */


class Pcdm4BrowserIndexChildrenTest extends Admin_AbstractControllerTestCase{
  protected $_storm_default_to_volatile = true;

  public function setUp() {
    parent::setUp();

    Class_AdminVar::set('CODIFICATION_BROWSER', 1);

    $mainstream = $this->fixture('Class_CodifPcdm4',
                                 ['id' => '0',
                                  'libelle' => 'Mainstream']);

    $notso = $this->fixture('Class_CodifPcdm4',
                            ['id' => '01',
                             'libelle' => 'Not so mainstream']);

    $notsoleaf = $this->fixture('Class_CodifPcdm4',
                            ['id' => '02',
                             'libelle' => 'Not so leaf']);

    $this->onLoaderOfModel('Class_CodifPcdm4')
         ->whenCalled('find')->with('0')->answers($mainstream)
         ->whenCalled('findParentOf')->with($mainstream)->answers(null)
         ->whenCalled('findNodesOfBy')->with($mainstream, [])->answers([$notso])
         ->whenCalled('recursiveNumberOfChildrenOf')->with($notso)->answers(1)

         ->whenCalled('findLeavesOfBy')
         ->with($mainstream, ['limitPage' => [null, 25],
                              'order' => 'id_pcdm4'])
         ->answers([$notsoleaf])

         ->whenCalled('findLeavesOfBy')
         ->with($mainstream, [])
         ->answers([$notsoleaf])

         ->beStrict();

    $this->dispatch('/admin/pcdm4-browser/index/parent_id/0', true);
  }


  /** @test */
  public function mainstreamShouldBeDisplay() {
    $this->assertXpathContentContains('//a', 'Mainstream', $this->_response->getBody());
  }


  /** @test */
  public function notsoShouldBeInTable() {
    $this->assertXpathContentContains('//td', 'Not so mainstream');
  }


  /** @test */
  public function notsoleafShouldBeInTable() {
    $this->assertXpathContentContains('//td', 'Not so leaf');
  }
}