Newer
Older
<?php
namespace calderawp\CalderaFormsQuery\Tests\Traits;
use calderawp\CalderaContainers\Service\Container;
use calderawp\CalderaFormsQuery\Features\FeatureContainer;
use calderawp\CalderaFormsQuery\SelectQueries;
use calderawp\CalderaFormsQuery\Tests\Unit\Features\QueriesTest;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
trait HasFactories
{
/**
* @return \calderawp\CalderaFormsQuery\Select\Entry
*/
protected function entryGeneratorFactory()
{
return new \calderawp\CalderaFormsQuery\Select\Entry(
$this->mySqlBuilderFactory(),
$this->entryTableName()
);
}
/**
* @return \calderawp\CalderaFormsQuery\Delete\Entry
*/
protected function entryDeleteGeneratorFactory()
{
return new \calderawp\CalderaFormsQuery\Delete\Entry(
$this->mySqlBuilderFactory(),
$this->entryTableName()
);
}
/**
* @return \calderawp\CalderaFormsQuery\Select\EntryValues
*/
protected function entryValuesGeneratorFactory()
{
return new \calderawp\CalderaFormsQuery\Select\EntryValues(
$this->mySqlBuilderFactory(),
$this->entryValueTableName()
);
}
/**
* @return \calderawp\CalderaFormsQuery\Delete\EntryValues
*/
protected function entryValuesDeleteGeneratorFactory()
{
return new \calderawp\CalderaFormsQuery\Delete\EntryValues(
$this->mySqlBuilderFactory(),
$this->entryValueTableName()
);
}
/**
* @return \calderawp\CalderaFormsQuery\MySqlBuilder
*/
protected function mySqlBuilderFactory()
{
return new \calderawp\CalderaFormsQuery\MySqlBuilder();
}
/**
$this->entryGeneratorFactory(),
$this->entryValuesGeneratorFactory(),
$this->getWPDB()
);
}
/**
* @return DeleteQueries
*/
protected function deleteQueriesFactory()
{
return new DeleteQueries(
$this->entryDeleteGeneratorFactory(),
$this->entryValuesDeleteGeneratorFactory(),
$this->getWPDB()
);
}
/**
* @return \calderawp\CalderaFormsQuery\Features\Queries
*/
protected function featureQueriesFactory()
{
return new \calderawp\CalderaFormsQuery\Features\Queries(
$this->selectQueriesFactory(),
$this->deleteQueriesFactory()
);
}
/**
* @return FeatureContainer
*/
protected function containerFactory()
{
return new FeatureContainer(
new Container(),
$this->getWPDB()
);
}
/**
* Gets a WPDB instance
*
* @return \wpdb
*/
protected function getWPDB()
{
global $wpdb;
include_once dirname(dirname(__FILE__)) . '/Mock/wpdb.php';
}
if (! $wpdb) {
$wpdb = new \wpdb('', '', '', '');
}
return $wpdb;
}
/**
* @return string
*/
protected function entryValueTableName(): string
{
return "{$this->getWPDB()->prefix}cf_form_entry_values";
}
/**
* @return string
*/
protected function entryTableName(): string
{
return "{$this->getWPDB()->prefix}cf_form_entries";
}
}