SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/tests/categoryTest.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. use Sprout\Helpers\Category;
  15.  
  16.  
  17.  
  18. /**
  19. * Test suite
  20. **/
  21. class categoryTest extends PHPUnit_Framework_TestCase
  22. {
  23.  
  24. public function dataInvalidTableValidation()
  25. {
  26. return [
  27. ['1'],
  28. ['1.1'],
  29. ['aaa.aaa'],
  30. [''],
  31. [null],
  32. [1],
  33. [false],
  34. [true],
  35. ];
  36. }
  37.  
  38. /**
  39.   * @dataProvider dataInvalidTableValidation
  40.   * @expectedException InvalidArgumentException
  41.   **/
  42. public function testTableMain2catValidationInvalid($val)
  43. {
  44. Category::tableMain2cat($val);
  45. }
  46.  
  47. /**
  48.   * @dataProvider dataInvalidTableValidation
  49.   * @expectedException InvalidArgumentException
  50.   **/
  51. public function testTableMain2joinerValidationInvalid($val)
  52. {
  53. Category::tableMain2joiner($val);
  54. }
  55.  
  56. /**
  57.   * @dataProvider dataInvalidTableValidation
  58.   * @expectedException InvalidArgumentException
  59.   **/
  60. public function testTableCat2mainValidationInvalid($val)
  61. {
  62. Category::tableCat2main($val);
  63. }
  64.  
  65.  
  66.  
  67. public function dataValidTableValidation()
  68. {
  69. return [
  70. ['pages'],
  71. ['articles'],
  72. ];
  73. }
  74.  
  75. /**
  76.   * @dataProvider dataValidTableValidation
  77.   **/
  78. public function testTableMain2catValidationValid($val)
  79. {
  80. $this->assertInternalType('string', Category::tableMain2cat($val));
  81. }
  82.  
  83. /**
  84.   * @dataProvider dataValidTableValidation
  85.   **/
  86. public function testTableMain2joinerValidationValid($val)
  87. {
  88. $this->assertInternalType('string', Category::tableMain2joiner($val));
  89. }
  90.  
  91. /**
  92.   * @dataProvider dataValidTableValidation
  93.   **/
  94. public function testTableCat2mainValidationValid($val)
  95. {
  96. $this->assertInternalType('string', Category::tableCat2main($val));
  97. }
  98.  
  99. }
  100.