tests/Activerules/Nugget/NuggetCoreTest.php
3. namespace Activerules\Nugget;
5. use PHPUnit\Framework\TestCase;
Extended class (NuggetCoreTest)
11. class NuggetCoreTest extends TestCase {
14. * This gets called before all test functions
16. public function setUp()
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');
34. * This gets called after each test function
36. public function tearDown()
38. //$this->myClass = null;
42. * An object missing required fields should fail.
44. public function testMissingCoreDataFails()
46. $result = $this->nugget->meetsSchema($this->missingCoreType, $this->nuggetSchema);
48. $this->assertEquals(false, $result);
52. * An object with valid core data should pass nugget validation
54. public function testValidRequiredCoreDataPasses()
56. $result = $this->nugget->meetsSchema($this->validCoreType, $this->nuggetSchema);
58. $this->assertEquals(true, $result);
63. * An object with invalid core data should fail nugget validation
65. public function testInvalidRequiredCoreDataFails()
67. $result = $this->nugget->meetsSchema($this->invalidCoreType, $this->nuggetSchema);
69. $this->assertEquals(false, $result);