本文整理汇总了PHP中Factory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::create方法的具体用法?PHP Factory::create怎么用?PHP Factory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_create_new
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);
}
示例2: test_create
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);
}
示例3: main
function main($k)
{
$x = Factory::create($k);
if ($x instanceof Derived) {
echo "derived\n";
}
}
示例4: __construct
function __construct($macro_nodes, $citeproc)
{
foreach ($macro_nodes as $macro) {
$macro = Factory::create($macro, $citeproc);
$this->elements[$macro->name()] = $macro;
}
}
示例5: init
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);
}
}
}
示例6: setUp
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();
}
示例7: testCreateBasicFactory
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);
}
示例8: init
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);
}
}
示例9: postCreate
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));
}
示例10: postCreate
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));
}
}
示例11: testShouldCreateCacheProviderNonConnectable
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);
}
示例12: setProvider
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;
}
示例13: init
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));
}
}
}
示例14: run
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";
}
示例15: findEc2Instances
/**
* @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;
}