PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.0
JetFormBuilder — Dynamic Blocks Form Builder v3.1.0
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / tests / wpunit / RepositoryTest.php
jetformbuilder / tests / wpunit Last commit date
BlockHelperTest.php 2 years ago RepositoryTest.php 2 years ago
RepositoryTest.php
96 lines
1 <?php
2
3 use Jet_Form_Builder\Exceptions\Repository_Exception;
4 use JFB_Components\Repository\Interfaces\Repository_Pattern_Interface;
5 use JFB_Components\Repository\Repository_Item_Instance_Trait;
6 use JFB_Components\Repository\Repository_Pattern_Trait;
7
8 class RepositoryTest extends \Codeception\TestCase\WPTestCase
9 {
10 /**
11 * @var \WpunitTester
12 */
13 protected $tester;
14 /**
15 * @var Repository_Pattern_Interface
16 */
17 protected $repository;
18
19 public function setUp(): void
20 {
21 // Before...
22 parent::setUp();
23
24 // Your set up methods here.
25 $this->repository = new class() implements Repository_Pattern_Interface {
26 use Repository_Pattern_Trait;
27
28 public function rep_instances(): array {
29 return array(
30 new class() implements Repository_Item_Instance_Trait {
31 public function rep_item_id() {
32 return 'first';
33 }
34 },
35 new class() implements Repository_Item_Instance_Trait {
36 public function rep_item_id() {
37 return 'second';
38 }
39 },
40 new class() implements Repository_Item_Instance_Trait {
41 public function rep_item_id() {
42 return 'third';
43 }
44 },
45 );
46 }
47 };
48 }
49
50 public function tearDown(): void
51 {
52 // Your tear down methods here.
53
54 // Then...
55 parent::tearDown();
56 }
57
58 public function testHasItems() {
59 $this->reset();
60
61 $this->assertCount( 3, $this->repository->rep_get_values() );
62 }
63
64 // tests
65 public function testGetById() {
66 $this->reset();
67
68 $this->assertTrue( $this->repository->rep_isset_item( 'first' ) );
69 $this->assertTrue( $this->repository->rep_isset_item( 'second' ) );
70 $this->assertTrue( $this->repository->rep_isset_item( 'third' ) );
71 }
72
73 public function testInstallNewItem() {
74 $this->reset();
75
76 try {
77 $this->repository->rep_install_item(
78 new class() implements Repository_Item_Instance_Trait {
79 public function rep_item_id() {
80 return 'new';
81 }
82 }
83 );
84 } catch ( Repository_Exception $exception ) {
85 $this->addWarning( $exception->getMessage() );
86 }
87
88 $this->assertTrue( $this->repository->rep_isset_item( 'new' ) );
89 }
90
91 protected function reset() {
92 $this->repository->rep_clear();
93 $this->repository->rep_install();
94 }
95 }
96