From b7244b79874f74b5d02e8de288e9506532266b36 Mon Sep 17 00:00:00 2001
From: Graham Campbell <graham@bugsnag.com>
Date: Fri, 29 Jul 2016 14:46:02 -0400
Subject: [PATCH] Added some very basic model tests

---
 composer.json                         |  2 +-
 composer.lock                         | 16 +++++++-------
 tests/Models/ComponentGroupTest.php   | 31 +++++++++++++++++++++++++++
 tests/Models/ComponentTest.php        | 31 +++++++++++++++++++++++++++
 tests/Models/IncidentTemplateTest.php | 31 +++++++++++++++++++++++++++
 tests/Models/IncidentTest.php         | 31 +++++++++++++++++++++++++++
 tests/Models/InviteTest.php           | 28 ++++++++++++++++++++++++
 tests/Models/MetricPointTest.php      | 31 +++++++++++++++++++++++++++
 tests/Models/MetricTest.php           | 31 +++++++++++++++++++++++++++
 tests/Models/ModelExistenceTest.php   | 30 ++++++++++++++++++++++++++
 tests/Models/SettingTest.php          | 28 ++++++++++++++++++++++++
 tests/Models/SubscriberTest.php       | 31 +++++++++++++++++++++++++++
 tests/Models/SubscriptionTest.php     | 31 +++++++++++++++++++++++++++
 tests/Models/TagTest.php              | 28 ++++++++++++++++++++++++
 tests/Models/UserTest.php             | 31 +++++++++++++++++++++++++++
 15 files changed, 402 insertions(+), 9 deletions(-)
 create mode 100644 tests/Models/ComponentGroupTest.php
 create mode 100644 tests/Models/ComponentTest.php
 create mode 100644 tests/Models/IncidentTemplateTest.php
 create mode 100644 tests/Models/IncidentTest.php
 create mode 100644 tests/Models/InviteTest.php
 create mode 100644 tests/Models/MetricPointTest.php
 create mode 100644 tests/Models/MetricTest.php
 create mode 100644 tests/Models/ModelExistenceTest.php
 create mode 100644 tests/Models/SettingTest.php
 create mode 100644 tests/Models/SubscriberTest.php
 create mode 100644 tests/Models/SubscriptionTest.php
 create mode 100644 tests/Models/TagTest.php
 create mode 100644 tests/Models/UserTest.php

diff --git a/composer.json b/composer.json
index 78d8232d528c..42fcafea1102 100644
--- a/composer.json
+++ b/composer.json
@@ -44,7 +44,7 @@
         "roumen/feed": "^2.10.4"
     },
     "require-dev": {
-        "alt-three/testbench": "^1.7",
+        "alt-three/testbench": "^1.8",
         "filp/whoops": "^2.1",
         "fzaninotto/faker": "^1.6",
         "graham-campbell/testbench-core": "^1.1",
diff --git a/composer.lock b/composer.lock
index 359bc0ae0647..8ebcbd84e8d4 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "bebdff554746dd7e0b24b4881e92191e",
-    "content-hash": "7c21d245d3c8c6f69ac1d98a58e4b761",
+    "hash": "efee15cdcec498c266017d8b6b9dc40b",
+    "content-hash": "5e0dba0b123506042e11f77f15280b6e",
     "packages": [
         {
             "name": "alt-three/badger",
@@ -4109,16 +4109,16 @@
     "packages-dev": [
         {
             "name": "alt-three/testbench",
-            "version": "v1.7.0",
+            "version": "v1.8.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/AltThree/TestBench.git",
-                "reference": "9bc6029a3a813dd20674548e45db5f6db0d1b4cd"
+                "reference": "35c6e02a36a14e6fb2084adf22922d78d04424af"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/AltThree/TestBench/zipball/9bc6029a3a813dd20674548e45db5f6db0d1b4cd",
-                "reference": "9bc6029a3a813dd20674548e45db5f6db0d1b4cd",
+                "url": "https://api.github.com/repos/AltThree/TestBench/zipball/35c6e02a36a14e6fb2084adf22922d78d04424af",
+                "reference": "35c6e02a36a14e6fb2084adf22922d78d04424af",
                 "shasum": ""
             },
             "require": {
@@ -4136,7 +4136,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.7-dev"
+                    "dev-master": "1.8-dev"
                 }
             },
             "autoload": {
@@ -4168,7 +4168,7 @@
                 "TestBench",
                 "app"
             ],
-            "time": "2016-07-24 13:16:43"
+            "time": "2016-07-29 18:38:43"
         },
         {
             "name": "doctrine/instantiator",
diff --git a/tests/Models/ComponentGroupTest.php b/tests/Models/ComponentGroupTest.php
new file mode 100644
index 000000000000..58a3d4a34358
--- /dev/null
+++ b/tests/Models/ComponentGroupTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\ComponentGroup;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the component group model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class ComponentGroupTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new ComponentGroup());
+    }
+}
diff --git a/tests/Models/ComponentTest.php b/tests/Models/ComponentTest.php
new file mode 100644
index 000000000000..8998d9b520a5
--- /dev/null
+++ b/tests/Models/ComponentTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\Component;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the component model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class ComponentTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new Component());
+    }
+}
diff --git a/tests/Models/IncidentTemplateTest.php b/tests/Models/IncidentTemplateTest.php
new file mode 100644
index 000000000000..5068e90d67e5
--- /dev/null
+++ b/tests/Models/IncidentTemplateTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\IncidentTemplate;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the incident template model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class IncidentTemplateTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new IncidentTemplate());
+    }
+}
diff --git a/tests/Models/IncidentTest.php b/tests/Models/IncidentTest.php
new file mode 100644
index 000000000000..541cb968f29d
--- /dev/null
+++ b/tests/Models/IncidentTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\Incident;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the incident model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class IncidentTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new Incident());
+    }
+}
diff --git a/tests/Models/InviteTest.php b/tests/Models/InviteTest.php
new file mode 100644
index 000000000000..7d590a6a6366
--- /dev/null
+++ b/tests/Models/InviteTest.php
@@ -0,0 +1,28 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use CachetHQ\Cachet\Models\Invite;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the invite model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class InviteTest extends AbstractTestCase
+{
+    public function testValidation()
+    {
+        $this->assertFalse(property_exists(new Invite(), 'rules'));
+    }
+}
diff --git a/tests/Models/MetricPointTest.php b/tests/Models/MetricPointTest.php
new file mode 100644
index 000000000000..10b7804fb584
--- /dev/null
+++ b/tests/Models/MetricPointTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\MetricPoint;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the metric point model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class MetricPointTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new MetricPoint());
+    }
+}
diff --git a/tests/Models/MetricTest.php b/tests/Models/MetricTest.php
new file mode 100644
index 000000000000..775773a35020
--- /dev/null
+++ b/tests/Models/MetricTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\Metric;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the metric model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class MetricTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new Metric());
+    }
+}
diff --git a/tests/Models/ModelExistenceTest.php b/tests/Models/ModelExistenceTest.php
new file mode 100644
index 000000000000..ed9f42fc3fc7
--- /dev/null
+++ b/tests/Models/ModelExistenceTest.php
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ExistenceTrait;
+use PHPUnit_Framework_TestCase as TestCase;
+
+/**
+ * This is the model existence test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class ModelExistenceTest extends TestCase
+{
+    use ExistenceTrait;
+
+    protected function getSourcePath()
+    {
+        return realpath(__DIR__.'/../../app/Models');
+    }
+}
diff --git a/tests/Models/SettingTest.php b/tests/Models/SettingTest.php
new file mode 100644
index 000000000000..5d88b3ac882e
--- /dev/null
+++ b/tests/Models/SettingTest.php
@@ -0,0 +1,28 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use CachetHQ\Cachet\Models\Setting;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the setting model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class SettingTest extends AbstractTestCase
+{
+    public function testValidation()
+    {
+        $this->assertFalse(property_exists(new Setting(), 'rules'));
+    }
+}
diff --git a/tests/Models/SubscriberTest.php b/tests/Models/SubscriberTest.php
new file mode 100644
index 000000000000..501c4d46cbd4
--- /dev/null
+++ b/tests/Models/SubscriberTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\Subscriber;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the subscriber model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class SubscriberTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new Subscriber());
+    }
+}
diff --git a/tests/Models/SubscriptionTest.php b/tests/Models/SubscriptionTest.php
new file mode 100644
index 000000000000..3bf172b77e13
--- /dev/null
+++ b/tests/Models/SubscriptionTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\Subscription;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the subscription model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class SubscriptionTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new Subscription());
+    }
+}
diff --git a/tests/Models/TagTest.php b/tests/Models/TagTest.php
new file mode 100644
index 000000000000..2a07d52cc07b
--- /dev/null
+++ b/tests/Models/TagTest.php
@@ -0,0 +1,28 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use CachetHQ\Cachet\Models\Tag;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the tag model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class TagTest extends AbstractTestCase
+{
+    public function testValidation()
+    {
+        $this->assertFalse(property_exists(new Tag(), 'rules'));
+    }
+}
diff --git a/tests/Models/UserTest.php b/tests/Models/UserTest.php
new file mode 100644
index 000000000000..b092d3152f21
--- /dev/null
+++ b/tests/Models/UserTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Cachet.
+ *
+ * (c) Alt Three Services Limited
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CachetHQ\Tests\Cachet\Models;
+
+use AltThree\TestBench\ValidationTrait;
+use CachetHQ\Cachet\Models\User;
+use CachetHQ\Tests\Cachet\AbstractTestCase;
+
+/**
+ * This is the user model test class.
+ *
+ * @author Graham Campbell <graham@alt-three.com>
+ */
+class UserTest extends AbstractTestCase
+{
+    use ValidationTrait;
+
+    public function testValidation()
+    {
+        $this->checkRules(new User());
+    }
+}