Skip to content
Snippets Groups Projects
Commit 05a38e51 authored by Josh Pollock's avatar Josh Pollock
Browse files

add a static accessor function for container

parent 9057feeb
No related branches found
No related tags found
No related merge requests found
<?php
namespace calderawp\CalderaFormsQuery\Tests\Integration;
use function calderawp\CalderaFormsQueries\CalderaFormsQueries;
use calderawp\CalderaFormsQuery\Features\FeatureContainer;
class FunctionsTest extends IntegrationTestCase
{
/**
* Ensure that accessor function returns the right class type
* @covers CalderaFormsQueries()
*/
public function testGetMainInstance()
{
$this->assertSame( FeatureContainer::class, get_class(CalderaFormsQueries()) );
}
/**
* Ensure that accessor function returns the same class instance
* @covers CalderaFormsQueries()
*/
public function testIsSameInstance()
{
$this->assertSame( CalderaFormsQueries(), CalderaFormsQueries() );
CalderaFormsQueries()->set('sivan', 'roy' );
$this->assertEquals( 'roy', CalderaFormsQueries()->get('sivan') );
}
}
\ No newline at end of file
......@@ -22,7 +22,8 @@
"autoload": {
"psr-4": {
"calderawp\\CalderaFormsQuery\\": "src"
}
},
"files": ["src/CalderaFormsQueries.php"]
},
"scripts" : {
"tests" : "composer unit-tests && composer wp-tests",
......
<?php
namespace calderawp\CalderaFormsQueries;
use calderawp\CalderaContainers\Service\Container;
use calderawp\CalderaFormsQuery\Features\FeatureContainer;
/**
* The CalderaFormsQueries
*
* Acts as static accessor for feature container
*
* @return FeatureContainer
*/
function CalderaFormsQueries()
{
static $CalderaFormsQueries;
if( ! $CalderaFormsQueries ){
global $wpdb;
$CalderaFormsQueries = new FeatureContainer(
new Container(),
$wpdb
);
}
return $CalderaFormsQueries;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment