tests/Activerules/Nugget/NuggetCoreTest.php

 
Procedures Status
NuggetCoreTest::setUp Issues 2
NuggetCoreTest::tearDown Testable
NuggetCoreTest::testMissingCoreDataFails Testable
NuggetCoreTest::testValidRequiredCoreDataPasses Testable
NuggetCoreTest::testInvalidRequiredCoreDataFails Testable
 
 
1. <?php
3. namespace Activerules\Nugget;
5. use PHPUnit\Framework\TestCase;
8. // Need more test
Extended class (NuggetCoreTest)  
11. class NuggetCoreTest extends TestCase {
13. /**
14. * This gets called before all test functions
15. */
16. public function setUp()
17. {
18. // Use the Activerules dereferencer
Static method call (Activerules\JsonReference\Dereferencer::draft4)  
19. $dereferencer = \Activerules\JsonReference\Dereferencer::draft4();
New instance (Activerules\Nugget\Nugget)  
21. $this->nugget = new \Activerules\Nugget\Nugget();
23. $this->nuggetSchema = $dereferencer->dereference('file://./nugget.json');
25. $this->missingCoreType = file_get_contents(__DIR__.'/objects/missingCoreType-Nugget.json');
27. $this->validCoreType = file_get_contents(__DIR__.'/objects/validCoreType-Nugget.json');
29. $this->invalidCoreType = file_get_contents(__DIR__.'/objects/invalidCoreType-Nugget.json');
31. }
33. /**
34. * This gets called after each test function
35. */
36. public function tearDown()
37. {
38. //$this->myClass = null;
39. }
41. /**
42. * An object missing required fields should fail.
43. */
44. public function testMissingCoreDataFails()
45. {
46. $result = $this->nugget->meetsSchema($this->missingCoreType, $this->nuggetSchema);
48. $this->assertEquals(false, $result);
49. }
51. /**
52. * An object with valid core data should pass nugget validation
53. */
54. public function testValidRequiredCoreDataPasses()
55. {
56. $result = $this->nugget->meetsSchema($this->validCoreType, $this->nuggetSchema);
58. $this->assertEquals(true, $result);
59. }
62. /**
63. * An object with invalid core data should fail nugget validation
64. */
65. public function testInvalidRequiredCoreDataFails()
66. {
67. $result = $this->nugget->meetsSchema($this->invalidCoreType, $this->nuggetSchema);
69. $this->assertEquals(false, $result);
70. }
71. }
 
Generated Thu, 11 Jan 2018 21:56:06 -0800 by PHP_Testability