public function test_create_new()
 {
     /** === Test Data === */
     $TRANS = 'transaction name';
     $CONN = 'connection name';
     /** === Setup Mocks === */
     // $result = $this->_manObj->create(\Praxigento\Core\Transaction\Database\Def\Item::class);
     $mResult = $this->_mock(\Praxigento\Core\Transaction\Database\Def\Item::class);
     $this->mManObj->shouldReceive('create')->once()->andReturn($mResult);
     // $result->setTransactionName($transactionName);
     $mResult->shouldReceive('setTransactionName')->once()->with($TRANS);
     // $result->setConnectionName($connectionName);
     $mResult->shouldReceive('setConnectionName')->once()->with($CONN);
     // $cfgData = $this->_configDeployment->get($cfgName);
     $mCfgData = [];
     $this->mConfigDeployment->shouldReceive('get')->once()->andReturn($mCfgData);
     // $conn = $this->_factoryConn->create($cfgData);
     $mConn = $this->_mock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
     $this->mFactoryConn->shouldReceive('create')->once()->andReturn($mConn);
     // $result->setConnection($conn);
     $mResult->shouldReceive('setConnection')->once();
     /** === Call and asserts  === */
     $res = $this->obj->create($TRANS, $CONN);
     $this->assertTrue($res instanceof \Praxigento\Core\Transaction\Database\IItem);
 }
Ejemplo n.º 2
0
 /**
  * Create instances of every cache frontend known to the system.
  * Method is to be used for delayed initialization of the iterator.
  *
  * @return void
  */
 protected function _initialize()
 {
     if ($this->_instances === null) {
         $this->_instances = array();
         foreach ($this->_getCacheSettings() as $frontendId => $frontendOptions) {
             $this->_instances[$frontendId] = $this->_factory->create($frontendOptions);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @codingStandardsIgnoreStart
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Magento\Framework\Pricing\PriceInfo\Base doesn't implement \Magento\Framework\Pricing\Price\PriceInterface
  * @codingStandardsIgnoreEnd
  */
 public function testCreateWithException()
 {
     $quantity = 2.2;
     $className = 'Magento\\Framework\\Pricing\\PriceInfo\\Base';
     $priceMock = $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
     $saleableItem = $this->getMock('Magento\\Framework\\Pricing\\Object\\SaleableInterface');
     $arguments = [];
     $argumentsResult = array_merge($arguments, ['saleableItem' => $saleableItem, 'quantity' => $quantity]);
     $this->objectManagerMock->expects($this->once())->method('create')->with($className, $argumentsResult)->will($this->returnValue($priceMock));
     $this->model->create($saleableItem, $className, $quantity, $arguments);
 }
 public function test_create()
 {
     /** === Test Data === */
     $NAME = 'name';
     /** === Setup Mocks === */
     // $result = $this->_manObj->create(\Praxigento\Core\Transaction\Business\Def\Item::class);
     $mResult = $this->_mock(\Praxigento\Core\Transaction\Business\Def\Item::class);
     $this->mManObj->shouldReceive('create')->once()->andReturn($mResult);
     // $result->setName($name);
     $mResult->shouldReceive('setName')->once()->with($NAME);
     /** === Call and asserts  === */
     $res = $this->obj->create($NAME);
     $this->assertTrue($res instanceof \Praxigento\Core\Transaction\Business\IItem);
 }
Ejemplo n.º 5
0
function main($k)
{
    $x = Factory::create($k);
    if ($x instanceof Derived) {
        echo "derived\n";
    }
}
Ejemplo n.º 6
0
 function __construct($macro_nodes, $citeproc)
 {
     foreach ($macro_nodes as $macro) {
         $macro = Factory::create($macro, $citeproc);
         $this->elements[$macro->name()] = $macro;
     }
 }
Ejemplo n.º 7
0
 function init($dom_node, $citeproc)
 {
     $etal = '';
     $tag = $dom_node->getElementsByTagName('substitute')->item(0);
     if ($tag) {
         $this->substitutes = Factory::create($tag, $citeproc);
         $dom_node->removeChild($tag);
     }
     $tag = $dom_node->getElementsByTagName('et-al')->item(0);
     if ($tag) {
         $etal = Factory::create($tag, $citeproc);
         $dom_node->removeChild($tag);
     }
     $var = $dom_node->getAttribute('variable');
     foreach ($dom_node->childNodes as $node) {
         if ($node->nodeType == 1) {
             $element = Factory::create($node, $citeproc);
             if ($element instanceof Label) {
                 $element->variable = $var;
             }
             if ($element instanceof Name && $etal) {
                 $element->etal = $etal;
             }
             $this->addElement($element);
         }
     }
 }
Ejemplo n.º 8
0
 public function setUp()
 {
     parent::setUp();
     Factory::create('migration', ['version' => '20140319-old_migration']);
     $this->service = $this->getMockBuilder('MigrationsService')->setMethods(['scan_migrations_dir', 'run_query', 'get_migration_contents'])->disableOriginalConstructor()->getMock();
     $this->service->expects($this->once())->method('scan_migrations_dir')->will($this->returnValue(['20140319-old_migration.sql', '20140319-new_migration.sql']));
     $this->service->initialize();
 }
Ejemplo n.º 9
0
 public function testCreateBasicFactory()
 {
     Configuration::$adapter = $this->getMockBuilder('\\Carpenter\\Adapter\\ArrayAdapter')->setMethods(['persist'])->getMock();
     $expected = ['username' => 'Bob', 'password' => 'password1'];
     Configuration::$adapter->expects($this->once())->method('persist')->will($this->returnValue($expected));
     $user = Factory::create('BasicUser');
     $this->assertEquals($expected, $user);
 }
Ejemplo n.º 10
0
 function init($dom_node, $citeproc)
 {
     $locale_elements = array();
     if ($form = $this->form) {
         $local_date = $this->citeproc->get_locale('date_options', $form);
         $dom_elem = dom_import_simplexml($local_date[0]);
         if ($dom_elem) {
             foreach ($dom_elem->childNodes as $node) {
                 if ($node->nodeType == 1) {
                     $locale_elements[] = Factory::create($node, $citeproc);
                 }
             }
         }
         //debug($dom_node->childNodes);
         foreach ($dom_node->childNodes as $node) {
             if ($node->nodeType == 1) {
                 $element = Factory::create($node, $citeproc);
                 foreach ($locale_elements as $key => $locale_element) {
                     if ($locale_element->name == $element->name) {
                         $locale_elements[$key]->attributes = array_merge($locale_element->attributes, $element->attributes);
                         $locale_elements[$key]->format = $element->format;
                         break;
                     } else {
                         $locale_elements[] = $element;
                     }
                 }
             }
         }
         if ($date_parts = $this->{'date-parts'}) {
             $parts = explode('-', $date_parts);
             foreach ($locale_elements as $key => $element) {
                 if (array_search($element->name, $parts) === FALSE) {
                     unset($locale_elements[$key]);
                 }
             }
             if (count($locale_elements) != count($parts)) {
                 foreach ($parts as $part) {
                     $element = new DatePart();
                     $element->name = $part;
                     $locale_elements[] = $element;
                 }
             }
             // now re-order the elements
             foreach ($parts as $part) {
                 foreach ($locale_elements as $key => $element) {
                     if ($element->name == $part) {
                         $this->elements[] = $element;
                         unset($locale_elements[$key]);
                     }
                 }
             }
         } else {
             $this->elements = $locale_elements;
         }
     } else {
         parent::init($dom_node, $citeproc);
     }
 }
Ejemplo n.º 11
0
 public function postCreate()
 {
     $number = $_POST['number'];
     $faker = Factory::create();
     $user = [];
     for ($i = 0; $i < $number; $i++) {
         $user[$i] = factory(p3\User::class)->create();
     }
     return view('ipsum.show', compact('user', $user));
 }
Ejemplo n.º 12
0
 public function postCreate(Request $request)
 {
     $number = $_POST['number'];
     //instantiate a faker generator
     $faker = Factory::create();
     for ($i = 0; $i < $number; $i++) {
         $text = $faker->paragraph;
         return view('ipsum.show', compact('text', $text));
     }
 }
Ejemplo n.º 13
0
 public function testShouldCreateCacheProviderNonConnectable()
 {
     $cacheSettings = ['adapter_name' => 'Array'];
     $factory = new Factory();
     $mockedProxy = $this->getMockBuilder('Pcelta\\Doctrine\\Cache\\Proxy')->setMethods(['getAdapter'])->getMock();
     $mockedProxy->expects($this->never())->method('getAdapter');
     $factory->setProxy($mockedProxy);
     $result = $factory->create($cacheSettings);
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $result);
 }
Ejemplo n.º 14
0
 private function setProvider($pos)
 {
     $this->providerName = $this->namedProvidersList[$pos];
     if (isset($this->providersList[$pos])) {
         $this->provider = $this->providersList[$pos];
         return;
     }
     $this->provider = Factory::create($this->namedProvidersList[$pos], $this->options, $this->cachedDir);
     $this->providersList[$pos] = $this->provider;
 }
Ejemplo n.º 15
0
 function init($dom_node, $citeproc)
 {
     if (!$dom_node) {
         return;
     }
     foreach ($dom_node->childNodes as $node) {
         if ($node->nodeType == 1) {
             $this->addElement(Factory::create($node, $citeproc));
         }
     }
 }
Ejemplo n.º 16
0
 function run()
 {
     //10+20=30
     $operate = Factory::create('Jia');
     $operate->a = 10;
     $operate->b = 20;
     echo $operate->getRes() . "\n";
     //100-20=80
     $operate = Factory::create('Jian');
     $operate->a = 100;
     $operate->b = 20;
     echo $operate->getRes() . "\n";
 }
Ejemplo n.º 17
0
 /**
  * @param array $filters
  * @return \AwsInspector\Model\Collection
  * @throws \Exception
  */
 public function findEc2Instances(array $filters = [])
 {
     $ec2Client = \AwsInspector\SdkFactory::getClient('ec2');
     /* @var $ec2Client \Aws\Ec2\Ec2Client */
     $result = $ec2Client->describeInstances(['Filters' => $filters]);
     $rows = $result->search('Reservations[].Instances[]');
     $collection = new \AwsInspector\Model\Collection();
     foreach ($rows as $row) {
         $instance = Factory::create($row);
         if ($instance !== false) {
             $collection->attach($instance);
         }
     }
     return $collection;
 }
Ejemplo n.º 18
0
}
class Factory
{
    public static function create($name)
    {
        if (class_exists($name)) {
            return new $name($int1, $int2);
        }
    }
}
/*There are two classes
1. Calculation
2. StringReverse
So create will have one of these as para.
*/
$Str = Factory::create("Calculation");
$choice = "";
echo "The Result Is: " . $Str->multiplication(5, 2);
/*
Multiplication gets two integers as para.
*/
$Str = Factory::create("StringReverse");
$Str->display("This is not a bug", "ALL", $Str);
/*
display (arg1,arg2,arg3)
arg1= The String to be reversed.
arg2= Type operation (For Example, To get the result for loop put "Loop", for Recursive just put "Recursive" or yu can put "All" to get both results)
arg3= This is the Object;
*/
//$Str->display("This is not a bug","ALL",$Str);
//echo $Str->multiplication(2,5,$Str);
Ejemplo n.º 19
0
 public function testCreateInvalid()
 {
     $this->setExpectedException('\\Aimeos\\MW\\MQueue\\Exception');
     Factory::create(array('adapter' => 'invalid'));
 }
Ejemplo n.º 20
0
<?php

if ($_POST['longUrl'] && isset($_POST['longUrl']) && $_POST['submit']) {
    require_once 'shortUrl.factory.class.php';
    $longUrl = $_POST['longUrl'];
    $site = $_POST['shorts'];
    if ($site === 'bitly') {
        $user = "******";
        $apikey = "R_0cf8415f0c3f9fcfd867ce7613e43fc7";
    } else {
        if ($site == 'digg') {
            $apikey = "http://thinkphp.ro";
        }
    }
    try {
        $ob = Factory::create($site, $longUrl, $user, $apikey);
        $shortUrl = $ob->getTinyUrl();
    } catch (Exception $e) {
        $shortUrl = $e->getMessage();
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
   <title>Shorten, share and track your links</title>
   <link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css">
   <style type="text/css">
html,body{background:#C5C7BE;margin:0;padding:0;}

#doc{background:#fff;border:1em solid #fff;}
Ejemplo n.º 21
0
 public function get_value()
 {
     $field = $this->field;
     return Factory::create($this->name, $this->custom_values)->{$field};
 }
Ejemplo n.º 22
0
 /**
  * @expectedException \Magento\Framework\Model\Exception
  */
 public function testExceptionCreate()
 {
     $this->factory->create('null', []);
 }
Ejemplo n.º 23
0
 /**
  * @expectedException Tystr\RestOrm\Exception\InvalidIdentifierMappingException
  */
 public function testCreateThrowsExceptionWhenMultiplePropertiesHaveAnIdentifierMapping()
 {
     $factory = new Factory();
     $factory->create('Tystr\\RestOrm\\Model\\BlogInvalidIdentifierMapping');
 }
Ejemplo n.º 24
0
 public function addChild($data)
 {
     $this->children[] = Factory::create($data);
 }
Ejemplo n.º 25
0
 /**
  * Create Db Instance
  *
  * @return BackupInterface
  */
 protected function _createDbBackupInstance()
 {
     return $this->_backupFactory->create(Factory::TYPE_DB)->setBackupExtension('gz')->setTime($this->getTime())->setBackupsDir($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::VAR_DIR))->setResourceModel($this->getResourceModel());
 }
Ejemplo n.º 26
0
 /**
  * 启动消息接收服务
  *
  * @param string $content 来自微信服务器的 HTTP 请求的 content
  *                        若留空则自动从 `php://input` 流中读取
  *
  * @return void
  */
 public function run($content = null)
 {
     extract($this->capture());
     if ($method === 'GET') {
         die($this->echostr($echostr, $signature, $timestamp, $nonce));
     }
     $content = $content !== null ?: file_get_contents('php://input');
     $message = Factory::create($this->messager->receive($msg_signature, $timestamp, $nonce, $content));
     $this->broadcast($message);
     $reply = $this->respond($message);
     if ($reply === null) {
         die;
     }
     $response = $this->messager->prepare($reply->toArray(), $timestamp, $nonce);
     echo $response;
 }
Ejemplo n.º 27
0
 /**
  * Gets accessor for instances of given class.
  * @param $class
  * @return Accessor
  */
 public function getAccessor($class)
 {
     return isset($this->accessors[$class]) ? $this->accessors[$class] : ($this->accessors[$class] = $this->factory->create($class));
 }
Ejemplo n.º 28
0
 /**
  * Trap for HTTP Exceptions.
  * XXX Handling for this needs to be configurable.
  * XXX More specific handling than just \Exception ...
  * Convert responses to JSON and return an appropriate hydrated data object.
  */
 private function _request($oRq)
 {
     try {
         $oRsp = $this->send($oRq);
         return Factory::create($oRsp->json());
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         $this->addException($e);
     } catch (\Exception $e) {
         $this->addException($e);
     }
 }
Ejemplo n.º 29
0
 function testRegisterUsingCallback()
 {
     $this->loader->register('f', function () {
         return Factory::create();
     });
     $obj = $this->loader->load('f');
     $this->assertTrue(is_object($obj));
     $this->assertEquals('Factory', get_class($obj));
 }
Ejemplo n.º 30
0
//字符串类
class String1
{
    public function write()
    {
    }
}
//Json类
class Json1
{
    public function getJsonData()
    {
    }
}
//xml类
class Xml1
{
    public function buildXml()
    {
    }
}
//工厂类
class Factory
{
    public static function create($class)
    {
        return new $class();
    }
}
Factory::create("Json1");
//获取Json对象