示例#1
0
 public function createNewServer()
 {
     $F = new Factory("xCal");
     $F->sA("xCalServerActive", "1");
     $F->sA("xCalUserID", Session::currentUser()->getID());
     $F->store();
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config_authentification_form');
     $factory = new Factory();
     $form = $factory->createForm($config);
     return $form;
 }
 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);
 }
示例#4
0
 /**
  * Executes this query and returns a QueryResult object.
  *
  * @return \PHPCR\Query\QueryInterface a QueryResult object
  * @throws \PHPCR\Query\InvalidQueryException if the query contains an unbound variable.
  * @throws \PHPCR\RepositoryException if an error occurs
  * @api
  */
 public function execute()
 {
     $transport = $this->objectmanager->getTransport();
     $rawData = $transport->querySQL($this->statement, $this->limit, $this->offset);
     $queryResult = $this->factory->get('Query\\QueryResult', array($rawData, $this->objectmanager));
     return $queryResult;
 }
 public function handle_create(Command\Create $cmd, Factory $factory)
 {
     $this->assert->not(Invariant\UserHasPendingCart::class);
     $cart = $factory->make_new();
     $cart->create($cmd->id, $cmd->customer_id);
     $this->repo->store($cart);
 }
示例#6
0
 public function createNew()
 {
     $F = new Factory("TinkerforgeBricklet");
     $F->sA("TinkerforgeBrickletTinkerforgeID", $this->getID());
     $F->store();
     echo $this->bricklets();
 }
 /**
  * Custom validator to check email array
  * 
  * @param  Factory $factory
  * @return $object
  */
 public function validator($factory)
 {
     $campaign_id = $this->route('campaigns');
     $validation = $factory->make($this->all(), $this->rules());
     $validation->each('add_user_email_notification', ['exists:user_has_roles,user_id,campaign_id,' . $campaign_id]);
     return $validation;
 }
示例#8
0
 function test_getReflection_should_return_instance_of_current_routed_class()
 {
     $route = new Factory('any', '/', 'DateTime', function () {
         return new \DateTime();
     });
     $refl = $route->getReflection('format');
     $this->assertInstanceOf('ReflectionMethod', $refl);
 }
示例#9
0
 public function testShouldFactoryTypeParserWhenSomeArgumentKeyIsANumber()
 {
     $factory = new Factory();
     $arguments = array('a' => true, 'b' => 42, 'c');
     $expectedInstanceType = 'PHPFluent\\Callback\\ArgumentParser\\Type';
     $actualInstance = $factory->parser($arguments);
     $this->assertInstanceOf($expectedInstanceType, $actualInstance);
 }
示例#10
0
 /**
  * Obtain the user information from the Social Login Provider.
  *
  * @param string $provider
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 protected function handleProviderCallback($provider)
 {
     $user = $this->socialite->driver($provider)->user();
     $user = \App\User::whereEmail($user->getEmail())->first() ?: \App\User::create(['name' => $user->getName(), 'email' => $user->getEmail()]);
     \Auth::login($user, true);
     flash(trans('auth.welcome', ['name' => $user->name]));
     return redirect(route('home'));
 }
示例#11
0
 public function testJsonFormatter()
 {
     $factory = new Factory();
     $format = $factory->build('json');
     $data = $format->convertToArray($this->rawData);
     $this->assertTrue(is_array($data));
     $this->assertCount(5, $data);
 }
示例#12
0
 /** creates the corresponding workspace */
 public function __construct($factory, Repository $repository, $workspaceName, \PHPCR\SimpleCredentials $credentials, TransportInterface $transport)
 {
     $this->factory = $factory;
     $this->repository = $repository;
     $this->objectManager = $this->factory->get('ObjectManager', array($transport, $this));
     $this->workspace = $this->factory->get('Workspace', array($this, $this->objectManager, $workspaceName));
     $this->credentials = $credentials;
 }
示例#13
0
 /**
  * [buildContent description]
  * @param  Factory $fieldFactory The field factory with all fields for the 
  *                               content
  * @param  array   $data         The content data, this should be specified
  *                               as ['group' => [$field_1, $field_2, ...], ...]
  *                               where $field_1 & $field_2 are a stdClass
  *                               objects containing at least 'field' and 
  *                               'value' properties
  * @param  string|ContentInterface $content Content class or class name
  * @return ContentInterface       Returns the build content
  */
 public function buildContent(Factory $fieldFactory, $data, $content = '\\Message\\Cog\\Field\\Content')
 {
     if (!$content instanceof ContentInterface) {
         if (!is_string($content)) {
             throw new \InvalidArgumentException('content must be either ContentInterface or string, ' . gettype($content) == 'object' ? get_class($content) : gettype($content) . ' given');
         }
         $content = new $content();
     }
     foreach ($fieldFactory as $name => $field) {
         if ($field instanceof Group && $field->isRepeatable()) {
             // add sequence variable
             $field->add($fieldFactory->getField('hidden', self::SEQUENCE_FIELD));
             $field = new RepeatableContainer($field);
         }
         $content->set($name, $field);
     }
     // Loop through the content, grouped by group
     foreach ($data as $groupName => $rows) {
         foreach ($rows as $row) {
             // If this field is in a group
             if ($groupName) {
                 $group = $content->get($groupName);
                 if (!$group) {
                     continue;
                 }
                 // Get the right group instance if it's a repeatable group
                 if ($group instanceof RepeatableContainer) {
                     // Ensure the right number of groups are defined
                     while (!$group->get($row->sequence)) {
                         $group->add();
                     }
                     $group = $group->get($row->sequence);
                     // set sequence field value
                     $group->get('_sequence')->setValue($row->sequence);
                 }
                 // Set the field
                 try {
                     $field = $group->{$row->field};
                 } catch (\OutOfBoundsException $e) {
                     continue;
                 }
             } else {
                 $field = $content->get($row->field);
             }
             // Skip the field if we can't find it
             if (!isset($field)) {
                 continue;
             }
             // Set the values
             if ($field instanceof MultipleValueField) {
                 $field->setValue($row->data_name, $row->value);
             } elseif ($field instanceof BaseField) {
                 $field->setValue($row->value);
             }
         }
     }
     return $content;
 }
 public function __construct(Factory $factory)
 {
     $this->factory = $factory;
     $this->db = $factory->getDb();
     $this->logger = $factory->getLogger();
     $this->mainTable = $this->getMainTable();
     $this->relationsTable = $this->getRelationsTable();
     $this->createTables();
 }
示例#15
0
 public function main()
 {
     $myShapes = array();
     $myFactory = new Factory();
     $myShapes = $myFactory->getShapes();
     foreach ($myShapes as $myShape) {
         $myShape->draw();
     }
 }
示例#16
0
 public function testBehaviorOwner()
 {
     $factory = new Factory('http://localhost/');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
     $factory->attachBehavior('my', new \Sokil\Rest\Client\MyBehavior());
     // exec behavior
     $requert = $factory->createRequest('GetRequestMock');
     $this->assertEquals('http://localhost/some/resource', $requert->getRequestUrl());
 }
示例#17
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);
         }
     }
 }
示例#18
0
 /**
  * Crawl comments page
  *
  * @param array $comment previously received comments page link
  * @param bool $proceed  proceed or not with received comments
  * @return array
  */
 public function crawlComments($comments, $proceed = true)
 {
     $importer = new Factory($this->plugin->config);
     $result = $importer->getImporter()->getComments($comments['page']);
     if ($result && $proceed) {
         $this->proceedPostComments($comments['postId'], $result);
     }
     return $result;
 }
示例#19
0
 /**
  * Custom validator to check email array
  * 
  * @param  Factory $factory
  * @return $object
  */
 public function validator($factory)
 {
     $landing_page_id = $this->route('landing_pages');
     $campaign_id = Landing_Page::where('id', $landing_page_id)->first()->campaign->id;
     // Validate email users are part of campaign
     $validation = $factory->make($this->all(), $this->rules());
     $validation->each('add_user_email_notification', ['exists:user_has_roles,user_id,campaign_id,' . $campaign_id]);
     return $validation;
 }
示例#20
0
 /**
  * @param int $zipcode
  * @return array
  */
 public function getLocationsFromZipCode($zipcode)
 {
     $locations = [];
     $items = $this->gateway->getLocationsFromZipCode($zipcode);
     foreach ($items as $item) {
         $locations[] = $this->factory->newLocation($item['id'], $item['name'], $item['type'], null, $item['idcity'] ? $this->factory->newCity($item['idcity'], $item['cityname']) : null);
     }
     return $locations;
 }
 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);
 }
示例#22
0
 /**
  *
  */
 public function __construct()
 {
     $factory = new Factory();
     $list = array();
     foreach ($this->regions as $regionDefinition) {
         $region = $factory->createFromArray($regionDefinition);
         $list[$region->getCode()] = $region;
     }
     parent::__construct($list);
 }
示例#23
0
 public function testGet()
 {
     $connection = new AmqpConnection();
     $connection->setConfig(['host' => $this->faker->ipv4, 'port' => $this->faker->randomDigit()]);
     $this->assertEquals('AMQPConnection', get_class($connection->get()));
     $amqpConnection = $this->getMockBuilder('AMQPConnection')->setMethods(['isConnected'])->getMock();
     $amqpConnection->expects($this->once())->method('isConnected')->willReturn(false);
     $connection->connection = $amqpConnection;
     $connection->get();
 }
示例#24
0
 /**
  * Repository constructor
  *
  * @param string  $name       Repository's name
  * @param Factory $factory    Factory
  * @param array   $parameters Parameters of the repository
  *
  * @api
  */
 public function __construct($name, Factory $factory, array $parameters = array())
 {
     $this->name = $name;
     $this->factory = $factory;
     $this->parameters = $parameters;
     $this->repository = function () use($factory, $parameters) {
         $factoryInstance = $factory->instanciate();
         return $factoryInstance->getRepository($parameters);
     };
 }
示例#25
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);
 }
示例#26
0
 /**
  * Creates a new query by specifying the query statement itself and the language
  * in which the query is stated. The $language must be a string from among
  * those returned by QueryManager.getSupportedQueryLanguages().
  *
  * @param string $statement
  * @param string $language
  * @return \PHPCR\Query\QueryInterface a Query object
  * @throws \PHPCR\Query\InvalidQueryException if the query statement is syntactically invalid or the specified language is not supported
  * @throws \PHPCR\RepositoryException if another error occurs
  * @api
  */
 public function createQuery($statement, $language)
 {
     switch ($language) {
         case \PHPCR\Query\QueryInterface::JCR_SQL2:
             return $this->factory->get('Query\\SqlQuery', array($statement, $this->objectmanager));
         case \PHPCR\Query\QueryInterface::JCR_JQOM:
             throw new NotImplementedException();
         default:
             throw new \PHPCR\Query\InvalidQueryException("No such query language: {$language}");
     }
 }
 public function registerEnvironment()
 {
     $this->app->bindShared('view', function ($app) {
         $resolver = $app['view.engine.resolver'];
         $finder = $app['view.finder'];
         $env = new Factory($resolver, $finder, $app['events']);
         $env->setContainer($app);
         $env->share('app', $app);
         return $env;
     });
 }
示例#28
0
 /**
  * @return mixed
  */
 public function getRenderer()
 {
     switch ($this->format) {
         case "json":
             return $this->factory->createJsonRenderer();
         case "html":
             return $this->factory->createHtmlRenderer();
         case "xml":
             return $this->factory->createXmlRenderer();
     }
 }
示例#29
0
 /**
  * Authenticates the user using the supplied credentials. If workspaceName is recognized as the
  * name of an existing workspace in the repository and authorization to access that workspace
  * is granted, then a new Session object is returned. workspaceName is a single string token.
  *
  * null credentials are currently not supported
  *
  * If workspaceName is null, a default workspace is automatically selected by the repository
  * implementation. This may, for example, be the "home workspace" of the user whose credentials
  * were passed, though this is entirely up to the configuration and implementation of the
  * repository. Alternatively, it may be a "null workspace" that serves only to provide the
  * method Workspace.getAccessibleWorkspaceNames(), allowing the client to select from among
  * available "real" workspaces.
  *
  * Note: The Java API defines this method with multiple differing signatures.
  *
  * @param \PHPCR\CredentialsInterface $credentials The credentials of the user
  * @param string $workspaceName the name of a workspace
  * @return \PHPCR\SessionInterface a valid session for the user to access the repository
  * @throws \PHPCR\LoginException if authentication or authorization (for the specified workspace) fails
  * @throws \PHPCR\NoSuchWorkspacexception if the specified workspaceName is not recognized
  * @throws \PHPCR\RepositoryException if another error occurs
  * @api
  */
 public function login($credentials = null, $workspaceName = null)
 {
     if ($workspaceName == null) {
         $workspaceName = 'default';
     }
     //TODO: can default workspace have other name?
     if (!$this->transport->login($credentials, $workspaceName)) {
         throw new \PHPCR\RepositoryException('transport failed to login without telling why');
     }
     $session = $this->factory->get('Session', array($this, $workspaceName, $credentials, $this->transport));
     return $session;
 }
示例#30
0
 public function addFrozenItem($name)
 {
     if (preg_match("/[0-9]+/", $name)) {
         $this->addEAN($name, false);
     } elseif (trim($name) != "") {
         $F = new Factory("Gefrierschrank");
         $F->sA("GefrierschrankName", $name);
         $F->sA("GefrierschrankAdded", "1");
         $F->store();
     }
     echo $this->getFrozenListTable();
 }