PHP Classes

File: vendor/gabordemooij/redbean/testing/RedUNIT/Base/Close.php

Recommend this page to a friend!
  Classes of Adrian M   upMVC   vendor/gabordemooij/redbean/testing/RedUNIT/Base/Close.php   Download  
File: vendor/gabordemooij/redbean/testing/RedUNIT/Base/Close.php
Role: Class source
Content type: text/plain
Description: Class source
Class: upMVC
Pure PHP web development without other frameworks
Author: By
Last change:
Date: 1 month ago
Size: 1,539 bytes
 

Contents

Class file image Download
<?php

namespace RedUNIT\Base;

use
RedUNIT\Base as Base;
use
RedBeanPHP\Facade as R;
use
RedBeanPHP\ToolBox as ToolBox;
use
RedBeanPHP\QueryWriter\SQLiteT as SQLiteT;

/**
 * Close
 *
 * Tests whether we can close the database connection.
 *
 * @file RedUNIT/Base/Close.php
 * @desc Tests database closing functionality.
 * @author Gabor de Mooij and the RedBeanPHP Community
 * @license New BSD/GPLv2
 *
 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
 * This source file is subject to the New BSD/GPLv2 License that is bundled
 * with this source code in the file license.txt.
 */
class Close extends Base
{
   
/**
     * Test closing database connection.
     *
     * @return void
     */
   
public function testClose()
    {
       
// Test whether we can select a specific feature set
       
R::useFeatureSet('novice/latest');
       
pass();
       
R::useFeatureSet('latest');
       
pass();
       
R::useFeatureSet('5.3');
       
pass();
       
R::useFeatureSet('novice/5.3');
       
pass();
        try {
           
R::useFeatureSet('5.2');
           
fail();
        } catch ( \
Exception $e ) {
           
asrt( $e->getMessage(), 'Unknown feature set label.' );
        }
        try {
           
R::nuke();
           
fail();
        } catch( \
Exception $e ) {
           
asrt( $e->getMessage(), 'The nuke() command has been disabled using noNuke() or R::feature(novice/...).' );
        }
       
R::useFeatureSet('latest');
       
//Close
       
R::getDatabaseAdapter()->setOption( 'setInitQuery', NULL );
       
asrt( R::getDatabaseAdapter()->getDatabase()->isConnected(), TRUE );
       
R::close();
       
asrt( R::getDatabaseAdapter()->getDatabase()->isConnected(), FALSE );
    }
}