Commit 65326361e26a83c5c712cb69bbfeffa4f2b061c7
1 parent
718ec4d1
test
Showing
116 changed files
with
273 additions
and
2065 deletions
Show diff stats
.gitignore
codeception.yml
| 1 | +<?php | |
| 2 | + namespace common\behaviors; | |
| 3 | + | |
| 4 | + use yii\base\Behavior; | |
| 5 | + use yii\base\ErrorException; | |
| 6 | + use yii\base\Event; | |
| 7 | + use yii\db\ActiveRecord; | |
| 8 | + use yii\helpers\Html; | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Class MapsBehavior | |
| 12 | + * @package common\behaviors | |
| 13 | + */ | |
| 14 | + class MapsBehavior extends Behavior | |
| 15 | + { | |
| 16 | + | |
| 17 | + public $location_attributes = [ ]; | |
| 18 | + | |
| 19 | + public $required_attributes = [ ]; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * @inheritdoc | |
| 23 | + */ | |
| 24 | + public function events() | |
| 25 | + { | |
| 26 | + return [ | |
| 27 | + ActiveRecord::EVENT_BEFORE_INSERT => 'beforeSave', | |
| 28 | + ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeSave', | |
| 29 | + ]; | |
| 30 | + } | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * After saving model get latitude (lat) and longitude (lng) from Google Map Api and insert | |
| 34 | + * to the database | |
| 35 | + * | |
| 36 | + * @param Event $event | |
| 37 | + * | |
| 38 | + * @return bool | |
| 39 | + * @throws ErrorException | |
| 40 | + */ | |
| 41 | + public function beforeSave($event) | |
| 42 | + { | |
| 43 | + /** | |
| 44 | + * @var ActiveRecord $owner | |
| 45 | + */ | |
| 46 | + $owner = $this->owner; | |
| 47 | + foreach($this->required_attributes as $required_attribute) { | |
| 48 | + if(empty( $owner->$required_attribute )) { | |
| 49 | + return true; | |
| 50 | + } | |
| 51 | + } | |
| 52 | + $location = ''; | |
| 53 | + $first = true; | |
| 54 | + foreach($this->location_attributes as $location_attribute) { | |
| 55 | + if(!$first) { | |
| 56 | + $location .= '+'; | |
| 57 | + } | |
| 58 | + $location .= $owner->$location_attribute; | |
| 59 | + $first = false; | |
| 60 | + } | |
| 61 | + $location = Html::encode($location); | |
| 62 | + $ch = curl_init(); | |
| 63 | + if(!$ch) { | |
| 64 | + throw new ErrorException('Curl error'); | |
| 65 | + } | |
| 66 | + curl_setopt($ch, CURLOPT_URL, "https://maps.googleapis.com/maps/api/geocode/json?address=" . $location); | |
| 67 | + curl_setopt($ch, CURLOPT_HEADER, 0); | |
| 68 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 69 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| 70 | + $result = json_decode(curl_exec($ch)); | |
| 71 | + curl_close($ch); | |
| 72 | + if(!empty($result->results)) { | |
| 73 | + $owner->lat = $result->results[0]->geometry->location->lat; | |
| 74 | + $owner->lng = $result->results[0]->geometry->location->lng; | |
| 75 | + } | |
| 76 | + return true; | |
| 77 | + } | |
| 78 | + } | |
| 0 | 79 | \ No newline at end of file | ... | ... |
common/models/Project.php
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | namespace common\models; |
| 4 | 4 | |
| 5 | + use common\behaviors\MapsBehavior; | |
| 5 | 6 | use common\modules\comment\models\CommentProject; |
| 6 | 7 | use common\modules\fileloader\behaviors\FileloaderBehavior; |
| 7 | 8 | use Yii; |
| ... | ... | @@ -76,6 +77,17 @@ |
| 76 | 77 | 'fileloader' => [ |
| 77 | 78 | 'class' => FileloaderBehavior::className(), |
| 78 | 79 | ], |
| 80 | + 'maps' => [ | |
| 81 | + 'class' => MapsBehavior::className(), | |
| 82 | + 'location_attributes' => [ | |
| 83 | + 'city', | |
| 84 | + 'street', | |
| 85 | + 'house', | |
| 86 | + ], | |
| 87 | + 'required_attributes' => [ | |
| 88 | + 'city', | |
| 89 | + ], | |
| 90 | + ], | |
| 79 | 91 | ]; |
| 80 | 92 | } |
| 81 | 93 | |
| ... | ... | @@ -160,7 +172,11 @@ |
| 160 | 172 | 'boolean', |
| 161 | 173 | ], |
| 162 | 174 | [ |
| 163 | - [ 'hidden', 'budget', 'total_budget' ], | |
| 175 | + [ | |
| 176 | + 'hidden', | |
| 177 | + 'budget', | |
| 178 | + 'total_budget', | |
| 179 | + ], | |
| 164 | 180 | 'default', |
| 165 | 181 | 'value' => 0, |
| 166 | 182 | ], | ... | ... |
console/migrations/m160504_145135_add_coordinates_columns_to_project_and_portfolio.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +use yii\db\Migration; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Handles adding coordinates_columns to table `project_and_portfolio`. | |
| 7 | + */ | |
| 8 | +class m160504_145135_add_coordinates_columns_to_project_and_portfolio extends Migration | |
| 9 | +{ | |
| 10 | + /** | |
| 11 | + * @inheritdoc | |
| 12 | + */ | |
| 13 | + public function up() | |
| 14 | + { | |
| 15 | + $this->addColumn('{{%project}}', 'lat', $this->string()); | |
| 16 | + $this->addColumn('{{%project}}', 'lng', $this->string()); | |
| 17 | + $this->addColumn('{{%portfolio}}', 'lat', $this->string()); | |
| 18 | + $this->addColumn('{{%portfolio}}', 'lng', $this->string()); | |
| 19 | + } | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * @inheritdoc | |
| 23 | + */ | |
| 24 | + public function down() | |
| 25 | + { | |
| 26 | + $this->dropColumn('{{%project}}', 'lat'); | |
| 27 | + $this->dropColumn('{{%project}}', 'lng'); | |
| 28 | + $this->dropColumn('{{%portfolio}}', 'lat'); | |
| 29 | + $this->dropColumn('{{%portfolio}}', 'lng'); | |
| 30 | + } | |
| 31 | +} | ... | ... |
frontend/views/performer/portfolio-view.php
| ... | ... | @@ -120,7 +120,7 @@ |
| 120 | 120 | <?php |
| 121 | 121 | foreach($portfolio->ShowGallery($portfolio->gallery->photo) as $one_photo) { |
| 122 | 122 | ?> |
| 123 | - <li><img src="<?= $one_photo ?>" alt=""/></li> | |
| 123 | + <li><img src="<?= $portfolio->minImg($one_photo, 210, 150) ?>" alt=""/></li> | |
| 124 | 124 | <?php |
| 125 | 125 | } |
| 126 | 126 | ?> | ... | ... |
frontend/views/site/index.php
| ... | ... | @@ -10,6 +10,26 @@ |
| 10 | 10 | $this->title = 'My Yii Application'; |
| 11 | 11 | ?> |
| 12 | 12 | <div class="section-box-1"> |
| 13 | + <?php | |
| 14 | + /* Yarik map fun | |
| 15 | + ?> | |
| 16 | + <div id="map_test" style="width:100%;height:500px;"> | |
| 17 | + | |
| 18 | + </div> | |
| 19 | + <script> | |
| 20 | + $(function() { | |
| 21 | + initMap(); | |
| 22 | + }); | |
| 23 | + var map; | |
| 24 | + function initMap() { | |
| 25 | + map = new google.maps.Map(document.getElementById('map_test'), { | |
| 26 | + center: {lat: -34.397, lng: 150.644}, | |
| 27 | + zoom: 8 | |
| 28 | + }) | |
| 29 | + } | |
| 30 | + </script> | |
| 31 | + */ | |
| 32 | + ?> | |
| 13 | 33 | <div class="box-wr"> |
| 14 | 34 | <div class="box-all"> |
| 15 | 35 | <div class="section-box-base"> |
| ... | ... | @@ -97,121 +117,121 @@ |
| 97 | 117 | <div class="shadow-map"></div> |
| 98 | 118 | <div id="map_cloud" style="display: none;"> |
| 99 | 119 | <script type="text/javascript"> |
| 100 | - function initialize() | |
| 101 | - { | |
| 102 | - var start_position = new google.maps.LatLng('56', '30'); | |
| 103 | - var settings = { | |
| 104 | - zoom : 7, scrollwheel : false, center : start_position, | |
| 105 | - mapTypeControl : false, | |
| 106 | - mapTypeControlOptions : {style : google.maps.MapTypeControlStyle.DROPDOWN_MENU}, | |
| 107 | - navigationControl : false, | |
| 108 | - navigationControlOptions : {style : google.maps.NavigationControlStyle.SMALL}, | |
| 109 | - scaleControl : false, streetViewControl : false, rotateControl : false, | |
| 110 | - zoomControl : true, mapTypeId : google.maps.MapTypeId.ROADMAP | |
| 111 | - }; | |
| 112 | - var map = new google.maps.Map(document.getElementById("map_canvas"), settings); | |
| 113 | - | |
| 114 | - var image1 = new google.maps.MarkerImage( | |
| 115 | - '/images/markers/marker-we-1.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 116 | - ); | |
| 117 | - var image2 = new google.maps.MarkerImage( | |
| 118 | - '/images/markers/marker-we-2.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 119 | - ); | |
| 120 | - var image3 = new google.maps.MarkerImage( | |
| 121 | - '/images/markers/marker-we-3.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 122 | - ); | |
| 123 | - var image4 = new google.maps.MarkerImage( | |
| 124 | - '/images/markers/marker-we-4.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 125 | - ); | |
| 126 | - var image5 = new google.maps.MarkerImage( | |
| 127 | - '/images/markers/marker-we-5.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 128 | - ); | |
| 129 | - var image6 = new google.maps.MarkerImage( | |
| 130 | - '/images/markers/marker-we-6.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 131 | - ); | |
| 132 | - var image7 = new google.maps.MarkerImage( | |
| 133 | - '/images/markers/marker-we-7.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 134 | - ); | |
| 135 | - var image8 = new google.maps.MarkerImage( | |
| 136 | - '/images/markers/marker-we-8.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 137 | - ); | |
| 138 | - var image9 = new google.maps.MarkerImage( | |
| 139 | - '/images/markers/marker-we-9.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 140 | - ); | |
| 141 | - var image10 = new google.maps.MarkerImage( | |
| 142 | - '/images/markers/marker-empl-1.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 143 | - ); | |
| 144 | - var image11 = new google.maps.MarkerImage( | |
| 145 | - '/images/markers/marker-empl-2.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 146 | - ); | |
| 147 | - var image12 = new google.maps.MarkerImage( | |
| 148 | - '/images/markers/marker-empl-3.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 149 | - ); | |
| 150 | - var image13 = new google.maps.MarkerImage( | |
| 151 | - '/images/markers/marker-empl-4.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 152 | - ); | |
| 153 | - var image14 = new google.maps.MarkerImage( | |
| 154 | - '/images/markers/marker-empl-5.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 155 | - ); | |
| 156 | - var image15 = new google.maps.MarkerImage( | |
| 157 | - '/images/markers/marker-empl-6.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 158 | - ); | |
| 159 | - var image16 = new google.maps.MarkerImage( | |
| 160 | - '/images/markers/marker-empl-7.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 161 | - ); | |
| 162 | - var image17 = new google.maps.MarkerImage( | |
| 163 | - '/images/markers/marker-empl-8.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 164 | - ); | |
| 165 | - var image18 = new google.maps.MarkerImage( | |
| 166 | - '/images/markers/marker-empl-9.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 167 | - ); | |
| 168 | - | |
| 169 | - var markers = []; | |
| 170 | - | |
| 171 | - var marker = new google.maps.Marker( | |
| 172 | - { | |
| 173 | - position : new google.maps.LatLng('56', '35.3'), map : map, | |
| 174 | - title : 'Marker Title2', icon : image1 | |
| 175 | - } | |
| 176 | - ); | |
| 177 | - markers.push(marker); | |
| 178 | - | |
| 179 | - var marker = new google.maps.Marker( | |
| 180 | - { | |
| 181 | - position : new google.maps.LatLng('56', '36'), map : map, | |
| 182 | - title : 'Marker Title2', icon : image2 | |
| 183 | - } | |
| 184 | - ); | |
| 185 | - markers.push(marker); | |
| 186 | - | |
| 187 | - var marker = new google.maps.Marker( | |
| 188 | - { | |
| 189 | - position : new google.maps.LatLng('56', '34.5'), map : map, | |
| 190 | - title : 'Marker Title3', icon : image18 | |
| 191 | - } | |
| 192 | - ); | |
| 193 | - markers.push(marker); | |
| 194 | - | |
| 195 | - var marker = new google.maps.Marker( | |
| 196 | - { | |
| 197 | - position : new google.maps.LatLng('56', '35'), map : map, | |
| 198 | - title : 'Marker Title4', icon : image13 | |
| 199 | - } | |
| 200 | - ); | |
| 201 | - markers.push(marker); | |
| 202 | - | |
| 203 | - var clusterStyles = [ | |
| 204 | - { | |
| 205 | - url : '/images/markers/clasters.png', height : 36, width : 36 | |
| 206 | - } | |
| 207 | - | |
| 208 | - ]; | |
| 209 | - markerClusterer = new MarkerClusterer( | |
| 210 | - map, markers, { | |
| 211 | - maxZoom : 10, gridSize : 100, styles : clusterStyles | |
| 212 | - } | |
| 213 | - ); | |
| 214 | - } | |
| 120 | + // function initialize() | |
| 121 | + // { | |
| 122 | + // var start_position = new google.maps.LatLng('56', '30'); | |
| 123 | + // var settings = { | |
| 124 | + // zoom : 7, scrollwheel : false, center : start_position, | |
| 125 | + // mapTypeControl : false, | |
| 126 | + // mapTypeControlOptions : {style : google.maps.MapTypeControlStyle.DROPDOWN_MENU}, | |
| 127 | + // navigationControl : false, | |
| 128 | + // navigationControlOptions : {style : google.maps.NavigationControlStyle.SMALL}, | |
| 129 | + // scaleControl : false, streetViewControl : false, rotateControl : false, | |
| 130 | + // zoomControl : true, mapTypeId : google.maps.MapTypeId.ROADMAP | |
| 131 | + // }; | |
| 132 | + // var map = new google.maps.Map(document.getElementById("map_canvas"), settings); | |
| 133 | + // | |
| 134 | + // var image1 = new google.maps.MarkerImage( | |
| 135 | + // '/images/markers/marker-we-1.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 136 | + // ); | |
| 137 | + // var image2 = new google.maps.MarkerImage( | |
| 138 | + // '/images/markers/marker-we-2.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 139 | + // ); | |
| 140 | + // var image3 = new google.maps.MarkerImage( | |
| 141 | + // '/images/markers/marker-we-3.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 142 | + // ); | |
| 143 | + // var image4 = new google.maps.MarkerImage( | |
| 144 | + // '/images/markers/marker-we-4.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 145 | + // ); | |
| 146 | + // var image5 = new google.maps.MarkerImage( | |
| 147 | + // '/images/markers/marker-we-5.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 148 | + // ); | |
| 149 | + // var image6 = new google.maps.MarkerImage( | |
| 150 | + // '/images/markers/marker-we-6.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 151 | + // ); | |
| 152 | + // var image7 = new google.maps.MarkerImage( | |
| 153 | + // '/images/markers/marker-we-7.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 154 | + // ); | |
| 155 | + // var image8 = new google.maps.MarkerImage( | |
| 156 | + // '/images/markers/marker-we-8.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 157 | + // ); | |
| 158 | + // var image9 = new google.maps.MarkerImage( | |
| 159 | + // '/images/markers/marker-we-9.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 160 | + // ); | |
| 161 | + // var image10 = new google.maps.MarkerImage( | |
| 162 | + // '/images/markers/marker-empl-1.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 163 | + // ); | |
| 164 | + // var image11 = new google.maps.MarkerImage( | |
| 165 | + // '/images/markers/marker-empl-2.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 166 | + // ); | |
| 167 | + // var image12 = new google.maps.MarkerImage( | |
| 168 | + // '/images/markers/marker-empl-3.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 169 | + // ); | |
| 170 | + // var image13 = new google.maps.MarkerImage( | |
| 171 | + // '/images/markers/marker-empl-4.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 172 | + // ); | |
| 173 | + // var image14 = new google.maps.MarkerImage( | |
| 174 | + // '/images/markers/marker-empl-5.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 175 | + // ); | |
| 176 | + // var image15 = new google.maps.MarkerImage( | |
| 177 | + // '/images/markers/marker-empl-6.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 178 | + // ); | |
| 179 | + // var image16 = new google.maps.MarkerImage( | |
| 180 | + // '/images/markers/marker-empl-7.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 181 | + // ); | |
| 182 | + // var image17 = new google.maps.MarkerImage( | |
| 183 | + // '/images/markers/marker-empl-8.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 184 | + // ); | |
| 185 | + // var image18 = new google.maps.MarkerImage( | |
| 186 | + // '/images/markers/marker-empl-9.png', new google.maps.Size(21, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 35) | |
| 187 | + // ); | |
| 188 | + // | |
| 189 | + // var markers = []; | |
| 190 | + // | |
| 191 | + // var marker = new google.maps.Marker( | |
| 192 | + // { | |
| 193 | + // position : new google.maps.LatLng('56', '35.3'), map : map, | |
| 194 | + // title : 'Marker Title2', icon : image1 | |
| 195 | + // } | |
| 196 | + // ); | |
| 197 | + // markers.push(marker); | |
| 198 | + // | |
| 199 | + // var marker = new google.maps.Marker( | |
| 200 | + // { | |
| 201 | + // position : new google.maps.LatLng('56', '36'), map : map, | |
| 202 | + // title : 'Marker Title2', icon : image2 | |
| 203 | + // } | |
| 204 | + // ); | |
| 205 | + // markers.push(marker); | |
| 206 | + // | |
| 207 | + // var marker = new google.maps.Marker( | |
| 208 | + // { | |
| 209 | + // position : new google.maps.LatLng('56', '34.5'), map : map, | |
| 210 | + // title : 'Marker Title3', icon : image18 | |
| 211 | + // } | |
| 212 | + // ); | |
| 213 | + // markers.push(marker); | |
| 214 | + // | |
| 215 | + // var marker = new google.maps.Marker( | |
| 216 | + // { | |
| 217 | + // position : new google.maps.LatLng('56', '35'), map : map, | |
| 218 | + // title : 'Marker Title4', icon : image13 | |
| 219 | + // } | |
| 220 | + // ); | |
| 221 | + // markers.push(marker); | |
| 222 | + // | |
| 223 | + // var clusterStyles = [ | |
| 224 | + // { | |
| 225 | + // url : '/images/markers/clasters.png', height : 36, width : 36 | |
| 226 | + // } | |
| 227 | + // | |
| 228 | + // ]; | |
| 229 | + // markerClusterer = new MarkerClusterer( | |
| 230 | + // map, markers, { | |
| 231 | + // maxZoom : 10, gridSize : 100, styles : clusterStyles | |
| 232 | + // } | |
| 233 | + // ); | |
| 234 | + // } | |
| 215 | 235 | </script> |
| 216 | 236 | </div> |
| 217 | 237 | <div id="map_canvas" style="width: 100%; height:100%;"></div> | ... | ... |
tests/README.md deleted
| 1 | -This directory contains various tests for the advanced applications. | |
| 2 | - | |
| 3 | -Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/). | |
| 4 | - | |
| 5 | -After creating and setting up the advanced application, follow these steps to prepare for the tests: | |
| 6 | - | |
| 7 | -1. Install Codeception if it's not yet installed: | |
| 8 | - | |
| 9 | - ``` | |
| 10 | - composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" | |
| 11 | - ``` | |
| 12 | - | |
| 13 | - If you've never used Composer for global packages run `composer global status`. It should output: | |
| 14 | - | |
| 15 | - ``` | |
| 16 | - Changed current directory to <directory> | |
| 17 | - ``` | |
| 18 | - | |
| 19 | - Then add `<directory>/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command | |
| 20 | - line globally. | |
| 21 | - | |
| 22 | -2. Install faker extension by running the following from template root directory where `composer.json` is: | |
| 23 | - | |
| 24 | - ``` | |
| 25 | - composer require --dev yiisoft/yii2-faker:* | |
| 26 | - ``` | |
| 27 | - | |
| 28 | -3. Create `yii2_advanced_tests` database then update it by applying migrations: | |
| 29 | - | |
| 30 | - ``` | |
| 31 | - codeception/bin/yii migrate | |
| 32 | - ``` | |
| 33 | - | |
| 34 | -4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in | |
| 35 | - webserver. In the root directory where `common`, `frontend` etc. are execute the following: | |
| 36 | - | |
| 37 | - ``` | |
| 38 | - php -S localhost:8080 | |
| 39 | - ``` | |
| 40 | - | |
| 41 | -5. Now you can run the tests with the following commands, assuming you are in the `tests/codeception` directory: | |
| 42 | - | |
| 43 | - ``` | |
| 44 | - # frontend tests | |
| 45 | - cd frontend | |
| 46 | - codecept build | |
| 47 | - codecept run | |
| 48 | - | |
| 49 | - # backend tests | |
| 50 | - | |
| 51 | - cd backend | |
| 52 | - codecept build | |
| 53 | - codecept run | |
| 54 | - | |
| 55 | - # etc. | |
| 56 | - ``` | |
| 57 | - | |
| 58 | - If you already have run `codecept build` for each application, you can skip that step and run all tests by a single `codecept run`. |
tests/_bootstrap.php
| 1 | 1 | <?php |
| 2 | - | |
| 3 | -defined('YII_DEBUG') or define('YII_DEBUG', true); | |
| 4 | -defined('YII_ENV') or define('YII_ENV', 'test'); | |
| 5 | - | |
| 6 | -require(__DIR__ . '/../vendor/autoload.php'); | |
| 7 | -require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); | |
| 8 | -require(__DIR__ . '/../common/config/bootstrap.php'); | |
| 9 | - | |
| 10 | -$config = yii\helpers\ArrayHelper::merge( | |
| 11 | - require(__DIR__ . '/../common/config/main.php'), | |
| 12 | - require(__DIR__ . '/../common/config/main-local.php'), | |
| 13 | - require(__DIR__ . '/config/main.php') | |
| 14 | - | |
| 15 | -); | |
| 16 | - | |
| 17 | -Yii::setAlias('@tests', dirname(__DIR__)); | |
| 18 | - | |
| 19 | -$application = new yii\web\Application($config); | |
| 20 | 2 | \ No newline at end of file |
| 3 | +// This is global bootstrap for autoloading | ... | ... |
tests/_data/ViewIllustrator_2001.jpg deleted
477 KB
tests/_support/AcceptanceTester.php
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * @method void am($role) |
| 13 | 13 | * @method void lookForwardTo($achieveValue) |
| 14 | 14 | * @method void comment($description) |
| 15 | - * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) | |
| 15 | + * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | |
| 16 | 16 | * |
| 17 | 17 | * @SuppressWarnings(PHPMD) |
| 18 | 18 | */ | ... | ... |
tests/_support/FunctionalTester.php
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * @method void am($role) |
| 13 | 13 | * @method void lookForwardTo($achieveValue) |
| 14 | 14 | * @method void comment($description) |
| 15 | - * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) | |
| 15 | + * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | |
| 16 | 16 | * |
| 17 | 17 | * @SuppressWarnings(PHPMD) |
| 18 | 18 | */ | ... | ... |
tests/_support/Helper/Acceptance.php
tests/_support/Helper/Functional.php
tests/_support/Helper/Unit.php
tests/_support/Step/Acceptance/CRMOperatorSteps.php deleted
| 1 | -<?php | |
| 2 | -namespace Step\Acceptance; | |
| 3 | - | |
| 4 | -class CRMOperatorSteps extends \AcceptanceTester | |
| 5 | -{ | |
| 6 | - public function amInAddCustomerUi(){ | |
| 7 | - $I = $this; | |
| 8 | - $I->amOnPage('site/signup'); | |
| 9 | - } | |
| 10 | - | |
| 11 | - public function imagineCustomer(){ | |
| 12 | - $fake = \Faker\Factory::create(); | |
| 13 | - return [ | |
| 14 | - 'SignupForm[username]' => $fake->name, | |
| 15 | - 'SignupForm[email]' => $fake->email, | |
| 16 | - 'SignupForm[password]' => $fake->password(19), | |
| 17 | - ]; | |
| 18 | - | |
| 19 | - } | |
| 20 | - | |
| 21 | - public function fillCustomerDataForm($fieldData){ | |
| 22 | - $I = $this; | |
| 23 | - foreach ($fieldData as $key=>$value) { | |
| 24 | - $I->fillField($key,$value); | |
| 25 | - } | |
| 26 | - | |
| 27 | - } | |
| 28 | - | |
| 29 | - public function submitCustomerDataForm(){ | |
| 30 | - $I = $this; | |
| 31 | - $I->click('signup-button'); | |
| 32 | - } | |
| 33 | - | |
| 34 | - | |
| 35 | - | |
| 36 | -} | |
| 37 | 0 | \ No newline at end of file |
tests/_support/UnitTester.php
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * @method void am($role) |
| 13 | 13 | * @method void lookForwardTo($achieveValue) |
| 14 | 14 | * @method void comment($description) |
| 15 | - * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) | |
| 15 | + * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | |
| 16 | 16 | * |
| 17 | 17 | * @SuppressWarnings(PHPMD) |
| 18 | 18 | */ | ... | ... |
tests/_support/_generated/AcceptanceTesterActions.php
tests/acceptance.suite.yml
tests/acceptance/FirstTestCept.php deleted
| 1 | -<?php | |
| 2 | -$I = new AcceptanceTester($scenario); | |
| 3 | -$I->wantTo('perform actions and see result'); | |
| 4 | -$I->amOnPage('/'); | |
| 5 | -$I->canSee('Проектантам'); | |
| 6 | -$I->click('Вход'); | |
| 7 | -$I->waitForElement('#modal_form_login', 15); | |
| 8 | -$I->canSee('Авторизация'); | |
| 9 | -$I->fillField('#loginform-username','admin'); | |
| 10 | -$I->fillField('#loginform-password','112233'); | |
| 11 | -$I->click('.login-button'); | |
| 12 | -$I->wait(1); | |
| 13 | -$I->canSee('admin@admin.com'); | |
| 14 | -$I->wait(1); | |
| 15 | -$I->amOnPage('/accounts/portfolio'); | |
| 16 | -$I->wait(1); | |
| 17 | -$I->click('Добавить'); | |
| 18 | -$I->wait(1); | |
| 19 | -$I->attachFile('input[type="file"]', 'ViewIllustrator_2001.jpg'); | |
| 20 | -$I->fillField('#portfolio-name',''); | |
| 21 | -$I->click('Добавить', '.input-blocks-wrapper'); | |
| 22 | -$I->see('Необходимо заполнить «name».','div'); |
tests/codeception.yml deleted
tests/codeception/_output/.gitignore deleted
tests/codeception/backend/.gitignore deleted
tests/codeception/backend/_bootstrap.php deleted
| 1 | -<?php | |
| 2 | -defined('YII_DEBUG') or define('YII_DEBUG', true); | |
| 3 | -defined('YII_ENV') or define('YII_ENV', 'test'); | |
| 4 | - | |
| 5 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); | |
| 6 | - | |
| 7 | -defined('YII_BACKEND_TEST_ENTRY_URL') or define('YII_BACKEND_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH)); | |
| 8 | -defined('YII_TEST_BACKEND_ENTRY_FILE') or define('YII_TEST_BACKEND_ENTRY_FILE', YII_APP_BASE_PATH . '/backend/web/index-test.php'); | |
| 9 | - | |
| 10 | -require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); | |
| 11 | -require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); | |
| 12 | -require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); | |
| 13 | -require_once(YII_APP_BASE_PATH . '/backend/config/bootstrap.php'); | |
| 14 | - | |
| 15 | -// set correct script paths | |
| 16 | - | |
| 17 | -// the entry script file path for functional and acceptance tests | |
| 18 | -$_SERVER['SCRIPT_FILENAME'] = YII_TEST_BACKEND_ENTRY_FILE; | |
| 19 | -$_SERVER['SCRIPT_NAME'] = YII_BACKEND_TEST_ENTRY_URL; | |
| 20 | -$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST); | |
| 21 | -$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80'; | |
| 22 | - | |
| 23 | -Yii::setAlias('@tests', dirname(dirname(__DIR__))); |
tests/codeception/backend/_output/.gitignore deleted
tests/codeception/backend/acceptance.suite.yml deleted
| 1 | -# Codeception Test Suite Configuration | |
| 2 | - | |
| 3 | -# suite for acceptance tests. | |
| 4 | -# perform tests in browser using the Selenium-like tools. | |
| 5 | -# powered by Mink (http://mink.behat.org). | |
| 6 | -# (tip: that's what your customer will see). | |
| 7 | -# (tip: test your ajax and javascript by one of Mink drivers). | |
| 8 | - | |
| 9 | -# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | |
| 10 | - | |
| 11 | -class_name: AcceptanceTester | |
| 12 | -modules: | |
| 13 | - enabled: | |
| 14 | - - PhpBrowser | |
| 15 | - - tests\codeception\common\_support\FixtureHelper | |
| 16 | -# you can use WebDriver instead of PhpBrowser to test javascript and ajax. | |
| 17 | -# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium | |
| 18 | -# "restart" option is used by the WebDriver to start each time per test-file new session and cookies, | |
| 19 | -# it is useful if you want to login in your app in each test. | |
| 20 | -# - WebDriver | |
| 21 | - config: | |
| 22 | - PhpBrowser: | |
| 23 | -# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO | |
| 24 | - url: http://localhost:8080 | |
| 25 | -# WebDriver: | |
| 26 | -# url: http://localhost:8080 | |
| 27 | -# browser: firefox | |
| 28 | -# restart: true |
tests/codeception/backend/acceptance/LoginCept.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -use tests\codeception\backend\AcceptanceTester; | |
| 4 | -use tests\codeception\common\_pages\LoginPage; | |
| 5 | - | |
| 6 | -/* @var $scenario Codeception\Scenario */ | |
| 7 | - | |
| 8 | -$I = new AcceptanceTester($scenario); | |
| 9 | -$I->wantTo('ensure login page works'); | |
| 10 | - | |
| 11 | -$loginPage = LoginPage::openBy($I); | |
| 12 | - | |
| 13 | -$I->amGoingTo('submit login form with no data'); | |
| 14 | -$loginPage->login('', ''); | |
| 15 | -if (method_exists($I, 'wait')) { | |
| 16 | - $I->wait(3); // only for selenium | |
| 17 | -} | |
| 18 | -$I->expectTo('see validations errors'); | |
| 19 | -$I->see('Username cannot be blank.', '.help-block'); | |
| 20 | -$I->see('Password cannot be blank.', '.help-block'); | |
| 21 | - | |
| 22 | -$I->amGoingTo('try to login with wrong credentials'); | |
| 23 | -$I->expectTo('see validations errors'); | |
| 24 | -$loginPage->login('admin', 'wrong'); | |
| 25 | -if (method_exists($I, 'wait')) { | |
| 26 | - $I->wait(3); // only for selenium | |
| 27 | -} | |
| 28 | -$I->expectTo('see validations errors'); | |
| 29 | -$I->see('Incorrect username or password.', '.help-block'); | |
| 30 | - | |
| 31 | -$I->amGoingTo('try to login with correct credentials'); | |
| 32 | -$loginPage->login('erau', 'password_0'); | |
| 33 | -if (method_exists($I, 'wait')) { | |
| 34 | - $I->wait(3); // only for selenium | |
| 35 | -} | |
| 36 | -$I->expectTo('see that user is logged'); | |
| 37 | -$I->seeLink('Logout (erau)'); | |
| 38 | -$I->dontSeeLink('Login'); | |
| 39 | -$I->dontSeeLink('Signup'); | |
| 40 | -/** Uncomment if using WebDriver | |
| 41 | - * $I->click('Logout (erau)'); | |
| 42 | - * $I->dontSeeLink('Logout (erau)'); | |
| 43 | - * $I->seeLink('Login'); | |
| 44 | - */ |
tests/codeception/backend/acceptance/_bootstrap.php deleted
tests/codeception/backend/codeception.yml deleted
| 1 | -namespace: tests\codeception\backend | |
| 2 | -actor: Tester | |
| 3 | -paths: | |
| 4 | - tests: . | |
| 5 | - log: _output | |
| 6 | - data: _data | |
| 7 | - helpers: _support | |
| 8 | -settings: | |
| 9 | - bootstrap: _bootstrap.php | |
| 10 | - suite_class: \PHPUnit_Framework_TestSuite | |
| 11 | - colors: true | |
| 12 | - memory_limit: 1024M | |
| 13 | - log: true | |
| 14 | -config: | |
| 15 | - # the entry script URL (with host info) for functional and acceptance tests | |
| 16 | - # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL | |
| 17 | - test_entry_url: http://localhost:8080/backend/web/index-test.php |
tests/codeception/backend/functional.suite.yml deleted
| 1 | -# Codeception Test Suite Configuration | |
| 2 | - | |
| 3 | -# suite for functional (integration) tests. | |
| 4 | -# emulate web requests and make application process them. | |
| 5 | -# (tip: better to use with frameworks). | |
| 6 | - | |
| 7 | -# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | |
| 8 | -#basic/web/index.php | |
| 9 | -class_name: FunctionalTester | |
| 10 | -modules: | |
| 11 | - enabled: | |
| 12 | - - Filesystem | |
| 13 | - - Yii2 | |
| 14 | - - tests\codeception\common\_support\FixtureHelper | |
| 15 | - config: | |
| 16 | - Yii2: | |
| 17 | - configFile: '../config/backend/functional.php' |
tests/codeception/backend/functional/LoginCept.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -use tests\codeception\backend\FunctionalTester; | |
| 4 | -use tests\codeception\common\_pages\LoginPage; | |
| 5 | - | |
| 6 | -/* @var $scenario Codeception\Scenario */ | |
| 7 | - | |
| 8 | -$I = new FunctionalTester($scenario); | |
| 9 | -$I->wantTo('ensure login page works'); | |
| 10 | - | |
| 11 | -$loginPage = LoginPage::openBy($I); | |
| 12 | - | |
| 13 | -$I->amGoingTo('submit login form with no data'); | |
| 14 | -$loginPage->login('', ''); | |
| 15 | -$I->expectTo('see validations errors'); | |
| 16 | -$I->see('Username cannot be blank.', '.help-block'); | |
| 17 | -$I->see('Password cannot be blank.', '.help-block'); | |
| 18 | - | |
| 19 | -$I->amGoingTo('try to login with wrong credentials'); | |
| 20 | -$I->expectTo('see validations errors'); | |
| 21 | -$loginPage->login('admin', 'wrong'); | |
| 22 | -$I->expectTo('see validations errors'); | |
| 23 | -$I->see('Incorrect username or password.', '.help-block'); | |
| 24 | - | |
| 25 | -$I->amGoingTo('try to login with correct credentials'); | |
| 26 | -$loginPage->login('erau', 'password_0'); | |
| 27 | -$I->expectTo('see that user is logged'); | |
| 28 | -$I->seeLink('Logout (erau)'); | |
| 29 | -$I->dontSeeLink('Login'); | |
| 30 | -$I->dontSeeLink('Signup'); |
tests/codeception/backend/functional/_bootstrap.php deleted
tests/codeception/backend/unit.suite.yml deleted
tests/codeception/backend/unit/DbTestCase.php deleted
tests/codeception/backend/unit/TestCase.php deleted
tests/codeception/backend/unit/_bootstrap.php deleted
tests/codeception/backend/unit/fixtures/data/.gitkeep deleted
tests/codeception/bin/_bootstrap.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Yii console bootstrap file. | |
| 4 | - * | |
| 5 | - * @link http://www.yiiframework.com/ | |
| 6 | - * @copyright Copyright (c) 2008 Yii Software LLC | |
| 7 | - * @license http://www.yiiframework.com/license/ | |
| 8 | - */ | |
| 9 | - | |
| 10 | -defined('YII_DEBUG') or define('YII_DEBUG', true); | |
| 11 | -defined('YII_ENV') or define('YII_ENV', 'test'); | |
| 12 | - | |
| 13 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); | |
| 14 | - | |
| 15 | -require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); | |
| 16 | -require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); | |
| 17 | -require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); | |
| 18 | - | |
| 19 | -Yii::setAlias('@tests', dirname(dirname(__DIR__))); |
tests/codeception/bin/yii deleted
| 1 | -#!/usr/bin/env php | |
| 2 | -<?php | |
| 3 | -/** | |
| 4 | - * Yii console bootstrap file. | |
| 5 | - * | |
| 6 | - * @link http://www.yiiframework.com/ | |
| 7 | - * @copyright Copyright (c) 2008 Yii Software LLC | |
| 8 | - * @license http://www.yiiframework.com/license/ | |
| 9 | - */ | |
| 10 | - | |
| 11 | -require_once __DIR__ . '/_bootstrap.php'; | |
| 12 | - | |
| 13 | -$config = yii\helpers\ArrayHelper::merge( | |
| 14 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 15 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 16 | - require(YII_APP_BASE_PATH . '/console/config/main.php'), | |
| 17 | - require(YII_APP_BASE_PATH . '/console/config/main-local.php'), | |
| 18 | - require(dirname(__DIR__) . '/config/config.php') | |
| 19 | -); | |
| 20 | - | |
| 21 | -$application = new yii\console\Application($config); | |
| 22 | -$exitCode = $application->run(); | |
| 23 | -exit($exitCode); |
tests/codeception/bin/yii.bat deleted
| 1 | -@echo off | |
| 2 | - | |
| 3 | -rem ------------------------------------------------------------- | |
| 4 | -rem Yii command line bootstrap script for Windows. | |
| 5 | -rem | |
| 6 | -rem @author Qiang Xue <qiang.xue@gmail.com> | |
| 7 | -rem @link http://www.yiiframework.com/ | |
| 8 | -rem @copyright Copyright (c) 2008 Yii Software LLC | |
| 9 | -rem @license http://www.yiiframework.com/license/ | |
| 10 | -rem ------------------------------------------------------------- | |
| 11 | - | |
| 12 | -@setlocal | |
| 13 | - | |
| 14 | -set YII_PATH=%~dp0 | |
| 15 | - | |
| 16 | -if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe | |
| 17 | - | |
| 18 | -"%PHP_COMMAND%" "%YII_PATH%yii" %* | |
| 19 | - | |
| 20 | -@endlocal |
tests/codeception/common/.gitignore deleted
tests/codeception/common/_bootstrap.php deleted
| 1 | -<?php | |
| 2 | -defined('YII_DEBUG') or define('YII_DEBUG', true); | |
| 3 | -defined('YII_ENV') or define('YII_ENV', 'test'); | |
| 4 | - | |
| 5 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); | |
| 6 | - | |
| 7 | -require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); | |
| 8 | -require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); | |
| 9 | -require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); | |
| 10 | - | |
| 11 | -// set correct script paths | |
| 12 | -$_SERVER['SERVER_NAME'] = 'localhost'; | |
| 13 | -$_SERVER['SERVER_PORT'] = '80'; | |
| 14 | - | |
| 15 | -Yii::setAlias('@tests', dirname(dirname(__DIR__))); |
tests/codeception/common/_output/.gitignore deleted
tests/codeception/common/_pages/LoginPage.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\common\_pages; | |
| 4 | - | |
| 5 | -use yii\codeception\BasePage; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * Represents loging page | |
| 9 | - * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester|\codeception_backend\AcceptanceTester|\codeception_backend\FunctionalTester $actor | |
| 10 | - */ | |
| 11 | -class LoginPage extends BasePage | |
| 12 | -{ | |
| 13 | - public $route = 'site/login'; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * @param string $username | |
| 17 | - * @param string $password | |
| 18 | - */ | |
| 19 | - public function login($username, $password) | |
| 20 | - { | |
| 21 | - $this->actor->fillField('input[name="LoginForm[username]"]', $username); | |
| 22 | - $this->actor->fillField('input[name="LoginForm[password]"]', $password); | |
| 23 | - $this->actor->click('login-button'); | |
| 24 | - } | |
| 25 | -} |
tests/codeception/common/_support/FixtureHelper.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\common\_support; | |
| 4 | - | |
| 5 | -use tests\codeception\common\fixtures\UserFixture; | |
| 6 | -use Codeception\Module; | |
| 7 | -use yii\test\FixtureTrait; | |
| 8 | -use yii\test\InitDbFixture; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * This helper is used to populate the database with needed fixtures before any tests are run. | |
| 12 | - * In this example, the database is populated with the demo login user, which is used in acceptance | |
| 13 | - * and functional tests. All fixtures will be loaded before the suite is started and unloaded after it | |
| 14 | - * completes. | |
| 15 | - */ | |
| 16 | -class FixtureHelper extends Module | |
| 17 | -{ | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * Redeclare visibility because codeception includes all public methods that do not start with "_" | |
| 21 | - * and are not excluded by module settings, in actor class. | |
| 22 | - */ | |
| 23 | - use FixtureTrait { | |
| 24 | - loadFixtures as protected; | |
| 25 | - fixtures as protected; | |
| 26 | - globalFixtures as protected; | |
| 27 | - unloadFixtures as protected; | |
| 28 | - getFixtures as protected; | |
| 29 | - getFixture as protected; | |
| 30 | - } | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * Method called before any suite tests run. Loads User fixture login user | |
| 34 | - * to use in acceptance and functional tests. | |
| 35 | - * @param array $settings | |
| 36 | - */ | |
| 37 | - public function _beforeSuite($settings = []) | |
| 38 | - { | |
| 39 | - $this->loadFixtures(); | |
| 40 | - } | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * Method is called after all suite tests run | |
| 44 | - */ | |
| 45 | - public function _afterSuite() | |
| 46 | - { | |
| 47 | - $this->unloadFixtures(); | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * @inheritdoc | |
| 52 | - */ | |
| 53 | - public function globalFixtures() | |
| 54 | - { | |
| 55 | - return [ | |
| 56 | - InitDbFixture::className(), | |
| 57 | - ]; | |
| 58 | - } | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * @inheritdoc | |
| 62 | - */ | |
| 63 | - public function fixtures() | |
| 64 | - { | |
| 65 | - return [ | |
| 66 | - 'user' => [ | |
| 67 | - 'class' => UserFixture::className(), | |
| 68 | - 'dataFile' => '@tests/codeception/common/fixtures/data/init_login.php', | |
| 69 | - ], | |
| 70 | - ]; | |
| 71 | - } | |
| 72 | -} |
tests/codeception/common/codeception.yml deleted
tests/codeception/common/fixtures/UserFixture.php deleted
tests/codeception/common/fixtures/data/init_login.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -return [ | |
| 4 | - [ | |
| 5 | - 'username' => 'erau', | |
| 6 | - 'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI', | |
| 7 | - // password_0 | |
| 8 | - 'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne', | |
| 9 | - 'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490', | |
| 10 | - 'created_at' => '1392559490', | |
| 11 | - 'updated_at' => '1392559490', | |
| 12 | - 'email' => 'sfriesen@jenkins.info', | |
| 13 | - ], | |
| 14 | -]; |
tests/codeception/common/templates/fixtures/user.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * @var $faker \Faker\Generator | |
| 4 | - * @var $index integer | |
| 5 | - */ | |
| 6 | - | |
| 7 | -$security = Yii::$app->getSecurity(); | |
| 8 | - | |
| 9 | -return [ | |
| 10 | - 'username' => $faker->userName, | |
| 11 | - 'email' => $faker->email, | |
| 12 | - 'auth_key' => $security->generateRandomString(), | |
| 13 | - 'password_hash' => $security->generatePasswordHash('password_' . $index), | |
| 14 | - 'password_reset_token' => $security->generateRandomString() . '_' . time(), | |
| 15 | - 'created_at' => time(), | |
| 16 | - 'updated_at' => time(), | |
| 17 | -]; |
tests/codeception/common/unit.suite.yml deleted
tests/codeception/common/unit/DbTestCase.php deleted
tests/codeception/common/unit/TestCase.php deleted
tests/codeception/common/unit/_bootstrap.php deleted
tests/codeception/common/unit/fixtures/data/models/user.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -return [ | |
| 4 | - [ | |
| 5 | - 'username' => 'bayer.hudson', | |
| 6 | - 'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR', | |
| 7 | - //password_0 | |
| 8 | - 'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO', | |
| 9 | - 'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317', | |
| 10 | - 'created_at' => '1402312317', | |
| 11 | - 'updated_at' => '1402312317', | |
| 12 | - 'email' => 'nicole.paucek@schultz.info', | |
| 13 | - ], | |
| 14 | -]; |
tests/codeception/common/unit/models/LoginFormTest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\common\unit\models; | |
| 4 | - | |
| 5 | -use Yii; | |
| 6 | -use tests\codeception\common\unit\DbTestCase; | |
| 7 | -use Codeception\Specify; | |
| 8 | -use common\models\LoginForm; | |
| 9 | -use tests\codeception\common\fixtures\UserFixture; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * Login form test | |
| 13 | - */ | |
| 14 | -class LoginFormTest extends DbTestCase | |
| 15 | -{ | |
| 16 | - | |
| 17 | - use Specify; | |
| 18 | - | |
| 19 | - public function setUp() | |
| 20 | - { | |
| 21 | - parent::setUp(); | |
| 22 | - | |
| 23 | - Yii::configure(Yii::$app, [ | |
| 24 | - 'components' => [ | |
| 25 | - 'user' => [ | |
| 26 | - 'class' => 'yii\web\User', | |
| 27 | - 'identityClass' => 'common\models\User', | |
| 28 | - ], | |
| 29 | - ], | |
| 30 | - ]); | |
| 31 | - } | |
| 32 | - | |
| 33 | - protected function tearDown() | |
| 34 | - { | |
| 35 | - Yii::$app->user->logout(); | |
| 36 | - parent::tearDown(); | |
| 37 | - } | |
| 38 | - | |
| 39 | - public function testLoginNoUser() | |
| 40 | - { | |
| 41 | - $model = new LoginForm([ | |
| 42 | - 'username' => 'not_existing_username', | |
| 43 | - 'password' => 'not_existing_password', | |
| 44 | - ]); | |
| 45 | - | |
| 46 | - $this->specify('user should not be able to login, when there is no identity', function () use ($model) { | |
| 47 | - expect('model should not login user', $model->login())->false(); | |
| 48 | - expect('user should not be logged in', Yii::$app->user->isGuest)->true(); | |
| 49 | - }); | |
| 50 | - } | |
| 51 | - | |
| 52 | - public function testLoginWrongPassword() | |
| 53 | - { | |
| 54 | - $model = new LoginForm([ | |
| 55 | - 'username' => 'bayer.hudson', | |
| 56 | - 'password' => 'wrong_password', | |
| 57 | - ]); | |
| 58 | - | |
| 59 | - $this->specify('user should not be able to login with wrong password', function () use ($model) { | |
| 60 | - expect('model should not login user', $model->login())->false(); | |
| 61 | - expect('error message should be set', $model->errors)->hasKey('password'); | |
| 62 | - expect('user should not be logged in', Yii::$app->user->isGuest)->true(); | |
| 63 | - }); | |
| 64 | - } | |
| 65 | - | |
| 66 | - public function testLoginCorrect() | |
| 67 | - { | |
| 68 | - | |
| 69 | - $model = new LoginForm([ | |
| 70 | - 'username' => 'bayer.hudson', | |
| 71 | - 'password' => 'password_0', | |
| 72 | - ]); | |
| 73 | - | |
| 74 | - $this->specify('user should be able to login with correct credentials', function () use ($model) { | |
| 75 | - expect('model should login user', $model->login())->true(); | |
| 76 | - expect('error message should not be set', $model->errors)->hasntKey('password'); | |
| 77 | - expect('user should be logged in', Yii::$app->user->isGuest)->false(); | |
| 78 | - }); | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * @inheritdoc | |
| 83 | - */ | |
| 84 | - public function fixtures() | |
| 85 | - { | |
| 86 | - return [ | |
| 87 | - 'user' => [ | |
| 88 | - 'class' => UserFixture::className(), | |
| 89 | - 'dataFile' => '@tests/codeception/common/unit/fixtures/data/models/user.php' | |
| 90 | - ], | |
| 91 | - ]; | |
| 92 | - } | |
| 93 | -} |
tests/codeception/config/acceptance.php deleted
tests/codeception/config/backend/acceptance.php deleted
| 1 | -<?php | |
| 2 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(dirname(__DIR__))))); | |
| 3 | - | |
| 4 | -/** | |
| 5 | - * Application configuration for backend acceptance tests | |
| 6 | - */ | |
| 7 | -return yii\helpers\ArrayHelper::merge( | |
| 8 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 9 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 10 | - require(YII_APP_BASE_PATH . '/backend/config/main.php'), | |
| 11 | - require(YII_APP_BASE_PATH . '/backend/config/main-local.php'), | |
| 12 | - require(dirname(__DIR__) . '/config.php'), | |
| 13 | - require(dirname(__DIR__) . '/acceptance.php'), | |
| 14 | - require(__DIR__ . '/config.php'), | |
| 15 | - [ | |
| 16 | - ] | |
| 17 | -); |
tests/codeception/config/backend/config.php deleted
tests/codeception/config/backend/functional.php deleted
| 1 | -<?php | |
| 2 | -$_SERVER['SCRIPT_FILENAME'] = YII_TEST_BACKEND_ENTRY_FILE; | |
| 3 | -$_SERVER['SCRIPT_NAME'] = YII_BACKEND_TEST_ENTRY_URL; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * Application configuration for backend functional tests | |
| 7 | - */ | |
| 8 | -return yii\helpers\ArrayHelper::merge( | |
| 9 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 10 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 11 | - require(YII_APP_BASE_PATH . '/backend/config/main.php'), | |
| 12 | - require(YII_APP_BASE_PATH . '/backend/config/main-local.php'), | |
| 13 | - require(dirname(__DIR__) . '/config.php'), | |
| 14 | - require(dirname(__DIR__) . '/functional.php'), | |
| 15 | - require(__DIR__ . '/config.php'), | |
| 16 | - [ | |
| 17 | - ] | |
| 18 | -); |
tests/codeception/config/backend/unit.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Application configuration for backend unit tests | |
| 5 | - */ | |
| 6 | -return yii\helpers\ArrayHelper::merge( | |
| 7 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 8 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 9 | - require(YII_APP_BASE_PATH . '/backend/config/main.php'), | |
| 10 | - require(YII_APP_BASE_PATH . '/backend/config/main-local.php'), | |
| 11 | - require(dirname(__DIR__) . '/config.php'), | |
| 12 | - require(dirname(__DIR__) . '/unit.php'), | |
| 13 | - require(__DIR__ . '/config.php'), | |
| 14 | - [ | |
| 15 | - ] | |
| 16 | -); |
tests/codeception/config/common/unit.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Application config for common unit tests | |
| 4 | - */ | |
| 5 | -return yii\helpers\ArrayHelper::merge( | |
| 6 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 7 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 8 | - require(dirname(__DIR__) . '/config.php'), | |
| 9 | - require(dirname(__DIR__) . '/unit.php'), | |
| 10 | - [ | |
| 11 | - 'id' => 'app-common', | |
| 12 | - 'basePath' => dirname(__DIR__), | |
| 13 | - ] | |
| 14 | -); |
tests/codeception/config/config.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Application configuration shared by all applications and test types | |
| 4 | - */ | |
| 5 | -return [ | |
| 6 | - 'language' => 'en-US', | |
| 7 | - 'controllerMap' => [ | |
| 8 | - 'fixture' => [ | |
| 9 | - 'class' => 'yii\faker\FixtureController', | |
| 10 | - 'fixtureDataPath' => '@tests/codeception/common/fixtures/data', | |
| 11 | - 'templatePath' => '@tests/codeception/common/templates/fixtures', | |
| 12 | - 'namespace' => 'tests\codeception\common\fixtures', | |
| 13 | - ], | |
| 14 | - ], | |
| 15 | - 'components' => [ | |
| 16 | - 'db' => [ | |
| 17 | - 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests', | |
| 18 | - ], | |
| 19 | - 'mailer' => [ | |
| 20 | - 'useFileTransport' => true, | |
| 21 | - ], | |
| 22 | - 'urlManager' => [ | |
| 23 | - 'showScriptName' => true, | |
| 24 | - ], | |
| 25 | - ], | |
| 26 | -]; |
tests/codeception/config/console/unit.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Application configuration for console unit tests | |
| 4 | - */ | |
| 5 | -return yii\helpers\ArrayHelper::merge( | |
| 6 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 7 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 8 | - require(YII_APP_BASE_PATH . '/console/config/main.php'), | |
| 9 | - require(YII_APP_BASE_PATH . '/console/config/main-local.php'), | |
| 10 | - require(dirname(__DIR__) . '/config.php'), | |
| 11 | - require(dirname(__DIR__) . '/unit.php'), | |
| 12 | - [ | |
| 13 | - ] | |
| 14 | -); |
tests/codeception/config/frontend/acceptance.php deleted
| 1 | -<?php | |
| 2 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(dirname(__DIR__))))); | |
| 3 | - | |
| 4 | -/** | |
| 5 | - * Application configuration for frontend acceptance tests | |
| 6 | - */ | |
| 7 | -return yii\helpers\ArrayHelper::merge( | |
| 8 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 9 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 10 | - require(YII_APP_BASE_PATH . '/frontend/config/main.php'), | |
| 11 | - require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'), | |
| 12 | - require(dirname(__DIR__) . '/config.php'), | |
| 13 | - require(dirname(__DIR__) . '/acceptance.php'), | |
| 14 | - require(__DIR__ . '/config.php'), | |
| 15 | - [ | |
| 16 | - ] | |
| 17 | -); |
tests/codeception/config/frontend/config.php deleted
tests/codeception/config/frontend/functional.php deleted
| 1 | -<?php | |
| 2 | -$_SERVER['SCRIPT_FILENAME'] = FRONTEND_ENTRY_FILE; | |
| 3 | -$_SERVER['SCRIPT_NAME'] = FRONTEND_ENTRY_URL; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * Application configuration for frontend functional tests | |
| 7 | - */ | |
| 8 | -return yii\helpers\ArrayHelper::merge( | |
| 9 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 10 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 11 | - require(YII_APP_BASE_PATH . '/frontend/config/main.php'), | |
| 12 | - require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'), | |
| 13 | - require(dirname(__DIR__) . '/config.php'), | |
| 14 | - require(dirname(__DIR__) . '/functional.php'), | |
| 15 | - require(__DIR__ . '/config.php'), | |
| 16 | - [ | |
| 17 | - ] | |
| 18 | -); |
tests/codeception/config/frontend/unit.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Application configuration for frontend unit tests | |
| 5 | - */ | |
| 6 | -return yii\helpers\ArrayHelper::merge( | |
| 7 | - require(YII_APP_BASE_PATH . '/common/config/main.php'), | |
| 8 | - require(YII_APP_BASE_PATH . '/common/config/main-local.php'), | |
| 9 | - require(YII_APP_BASE_PATH . '/frontend/config/main.php'), | |
| 10 | - require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'), | |
| 11 | - require(dirname(__DIR__) . '/config.php'), | |
| 12 | - require(dirname(__DIR__) . '/unit.php'), | |
| 13 | - require(__DIR__ . '/config.php'), | |
| 14 | - [ | |
| 15 | - ] | |
| 16 | -); |
tests/codeception/config/functional.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Application configuration shared by all applications functional tests | |
| 4 | - */ | |
| 5 | -return [ | |
| 6 | - 'components' => [ | |
| 7 | - 'request' => [ | |
| 8 | - // it's not recommended to run functional tests with CSRF validation enabled | |
| 9 | - 'enableCsrfValidation' => false, | |
| 10 | - // but if you absolutely need it set cookie domain to localhost | |
| 11 | - /* | |
| 12 | - 'csrfCookie' => [ | |
| 13 | - 'domain' => 'localhost', | |
| 14 | - ], | |
| 15 | - */ | |
| 16 | - ], | |
| 17 | - ], | |
| 18 | -]; | |
| 19 | 0 | \ No newline at end of file |
tests/codeception/config/unit.php deleted
tests/codeception/console/.gitignore deleted
tests/codeception/console/_bootstrap.php deleted
| 1 | -<?php | |
| 2 | -defined('YII_DEBUG') or define('YII_DEBUG', true); | |
| 3 | -defined('YII_ENV') or define('YII_ENV', 'test'); | |
| 4 | - | |
| 5 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); | |
| 6 | - | |
| 7 | -require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); | |
| 8 | -require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); | |
| 9 | -require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); | |
| 10 | -require_once(YII_APP_BASE_PATH . '/console/config/bootstrap.php'); | |
| 11 | - | |
| 12 | -// set correct script paths | |
| 13 | -$_SERVER['SERVER_NAME'] = 'localhost'; | |
| 14 | -$_SERVER['SERVER_PORT'] = '80'; | |
| 15 | - | |
| 16 | -Yii::setAlias('@tests', dirname(dirname(__DIR__))); |
tests/codeception/console/_output/.gitignore deleted
tests/codeception/console/codeception.yml deleted
tests/codeception/console/unit.suite.yml deleted
tests/codeception/console/unit/DbTestCase.php deleted
tests/codeception/console/unit/TestCase.php deleted
tests/codeception/console/unit/_bootstrap.php deleted
tests/codeception/console/unit/fixtures/data/.gitkeep deleted
tests/codeception/frontend/.gitignore deleted
tests/codeception/frontend/_bootstrap.php deleted
| 1 | -<?php | |
| 2 | -defined('YII_DEBUG') or define('YII_DEBUG', true); | |
| 3 | -defined('YII_ENV') or define('YII_ENV', 'test'); | |
| 4 | - | |
| 5 | -defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); | |
| 6 | - | |
| 7 | -defined('FRONTEND_ENTRY_URL') or define('FRONTEND_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH)); | |
| 8 | -defined('FRONTEND_ENTRY_FILE') or define('FRONTEND_ENTRY_FILE', YII_APP_BASE_PATH . '/frontend/web/index-test.php'); | |
| 9 | - | |
| 10 | -require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); | |
| 11 | -require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); | |
| 12 | -require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); | |
| 13 | -require_once(YII_APP_BASE_PATH . '/frontend/config/bootstrap.php'); | |
| 14 | - | |
| 15 | -// set correct script paths | |
| 16 | - | |
| 17 | -// the entry script file path for functional and acceptance tests | |
| 18 | -$_SERVER['SCRIPT_FILENAME'] = FRONTEND_ENTRY_FILE; | |
| 19 | -$_SERVER['SCRIPT_NAME'] = FRONTEND_ENTRY_URL; | |
| 20 | -$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST); | |
| 21 | -$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80'; | |
| 22 | - | |
| 23 | -Yii::setAlias('@tests', dirname(dirname(__DIR__))); |
tests/codeception/frontend/_output/.gitignore deleted
tests/codeception/frontend/_pages/AboutPage.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\_pages; | |
| 4 | - | |
| 5 | -use yii\codeception\BasePage; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * Represents about page | |
| 9 | - * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor | |
| 10 | - */ | |
| 11 | -class AboutPage extends BasePage | |
| 12 | -{ | |
| 13 | - public $route = 'site/about'; | |
| 14 | -} |
tests/codeception/frontend/_pages/ContactPage.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\_pages; | |
| 4 | - | |
| 5 | -use yii\codeception\BasePage; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * Represents contact page | |
| 9 | - * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor | |
| 10 | - */ | |
| 11 | -class ContactPage extends BasePage | |
| 12 | -{ | |
| 13 | - public $route = 'site/contact'; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * @param array $contactData | |
| 17 | - */ | |
| 18 | - public function submit(array $contactData) | |
| 19 | - { | |
| 20 | - foreach ($contactData as $field => $value) { | |
| 21 | - $inputType = $field === 'body' ? 'textarea' : 'input'; | |
| 22 | - $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); | |
| 23 | - } | |
| 24 | - $this->actor->click('contact-button'); | |
| 25 | - } | |
| 26 | -} |
tests/codeception/frontend/_pages/SignupPage.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\_pages; | |
| 4 | - | |
| 5 | -use \yii\codeception\BasePage; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * Represents signup page | |
| 9 | - * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor | |
| 10 | - */ | |
| 11 | -class SignupPage extends BasePage | |
| 12 | -{ | |
| 13 | - | |
| 14 | - public $route = 'site/signup'; | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * @param array $signupData | |
| 18 | - */ | |
| 19 | - public function submit(array $signupData) | |
| 20 | - { | |
| 21 | - foreach ($signupData as $field => $value) { | |
| 22 | - $inputType = $field === 'body' ? 'textarea' : 'input'; | |
| 23 | - $this->actor->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value); | |
| 24 | - } | |
| 25 | - $this->actor->click('signup-button'); | |
| 26 | - } | |
| 27 | -} |
tests/codeception/frontend/acceptance.suite.yml deleted
| 1 | -# Codeception Test Suite Configuration | |
| 2 | - | |
| 3 | -# suite for acceptance tests. | |
| 4 | -# perform tests in browser using the Selenium-like tools. | |
| 5 | -# powered by Mink (http://mink.behat.org). | |
| 6 | -# (tip: that's what your customer will see). | |
| 7 | -# (tip: test your ajax and javascript by one of Mink drivers). | |
| 8 | - | |
| 9 | -# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | |
| 10 | - | |
| 11 | -class_name: AcceptanceTester | |
| 12 | -modules: | |
| 13 | - enabled: | |
| 14 | - - PhpBrowser | |
| 15 | - - tests\codeception\common\_support\FixtureHelper | |
| 16 | -# you can use WebDriver instead of PhpBrowser to test javascript and ajax. | |
| 17 | -# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium | |
| 18 | -# "restart" option is used by the WebDriver to start each time per test-file new session and cookies, | |
| 19 | -# it is useful if you want to login in your app in each test. | |
| 20 | -# - WebDriver | |
| 21 | - config: | |
| 22 | - PhpBrowser: | |
| 23 | -# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO | |
| 24 | - url: http://localhost:8080 | |
| 25 | -# WebDriver: | |
| 26 | -# url: http://localhost:8080 | |
| 27 | -# browser: firefox | |
| 28 | -# restart: true |
tests/codeception/frontend/acceptance/AboutCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\AcceptanceTester; | |
| 3 | -use tests\codeception\frontend\_pages\AboutPage; | |
| 4 | - | |
| 5 | -/* @var $scenario Codeception\Scenario */ | |
| 6 | - | |
| 7 | -$I = new AcceptanceTester($scenario); | |
| 8 | -$I->wantTo('ensure that about works'); | |
| 9 | -AboutPage::openBy($I); | |
| 10 | -$I->see('About', 'h1'); |
tests/codeception/frontend/acceptance/ContactCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\AcceptanceTester; | |
| 3 | -use tests\codeception\frontend\_pages\ContactPage; | |
| 4 | - | |
| 5 | -/* @var $scenario Codeception\Scenario */ | |
| 6 | - | |
| 7 | -$I = new AcceptanceTester($scenario); | |
| 8 | -$I->wantTo('ensure that contact works'); | |
| 9 | - | |
| 10 | -$contactPage = ContactPage::openBy($I); | |
| 11 | - | |
| 12 | -$I->see('Contact', 'h1'); | |
| 13 | - | |
| 14 | -$I->amGoingTo('submit contact form with no data'); | |
| 15 | -$contactPage->submit([]); | |
| 16 | -if (method_exists($I, 'wait')) { | |
| 17 | - $I->wait(3); // only for selenium | |
| 18 | -} | |
| 19 | -$I->expectTo('see validations errors'); | |
| 20 | -$I->see('Contact', 'h1'); | |
| 21 | -$I->see('Name cannot be blank', '.help-block'); | |
| 22 | -$I->see('Email cannot be blank', '.help-block'); | |
| 23 | -$I->see('Subject cannot be blank', '.help-block'); | |
| 24 | -$I->see('Body cannot be blank', '.help-block'); | |
| 25 | -$I->see('The verification code is incorrect', '.help-block'); | |
| 26 | - | |
| 27 | -$I->amGoingTo('submit contact form with not correct email'); | |
| 28 | -$contactPage->submit([ | |
| 29 | - 'name' => 'tester', | |
| 30 | - 'email' => 'tester.email', | |
| 31 | - 'subject' => 'test subject', | |
| 32 | - 'body' => 'test content', | |
| 33 | - 'verifyCode' => 'testme', | |
| 34 | -]); | |
| 35 | -if (method_exists($I, 'wait')) { | |
| 36 | - $I->wait(3); // only for selenium | |
| 37 | -} | |
| 38 | -$I->expectTo('see that email adress is wrong'); | |
| 39 | -$I->dontSee('Name cannot be blank', '.help-block'); | |
| 40 | -$I->see('Email is not a valid email address.', '.help-block'); | |
| 41 | -$I->dontSee('Subject cannot be blank', '.help-block'); | |
| 42 | -$I->dontSee('Body cannot be blank', '.help-block'); | |
| 43 | -$I->dontSee('The verification code is incorrect', '.help-block'); | |
| 44 | - | |
| 45 | -$I->amGoingTo('submit contact form with correct data'); | |
| 46 | -$contactPage->submit([ | |
| 47 | - 'name' => 'tester', | |
| 48 | - 'email' => 'tester@example.com', | |
| 49 | - 'subject' => 'test subject', | |
| 50 | - 'body' => 'test content', | |
| 51 | - 'verifyCode' => 'testme', | |
| 52 | -]); | |
| 53 | -if (method_exists($I, 'wait')) { | |
| 54 | - $I->wait(3); // only for selenium | |
| 55 | -} | |
| 56 | -$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); |
tests/codeception/frontend/acceptance/HomeCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\AcceptanceTester; | |
| 3 | - | |
| 4 | -/* @var $scenario Codeception\Scenario */ | |
| 5 | - | |
| 6 | -$I = new AcceptanceTester($scenario); | |
| 7 | -$I->wantTo('ensure that home page works'); | |
| 8 | -$I->amOnPage(Yii::$app->homeUrl); | |
| 9 | -$I->see('My Company'); | |
| 10 | -$I->seeLink('About'); | |
| 11 | -$I->click('About'); | |
| 12 | -$I->see('This is the About page.'); |
tests/codeception/frontend/acceptance/LoginCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\AcceptanceTester; | |
| 3 | -use tests\codeception\common\_pages\LoginPage; | |
| 4 | - | |
| 5 | -/* @var $scenario Codeception\Scenario */ | |
| 6 | - | |
| 7 | -$I = new AcceptanceTester($scenario); | |
| 8 | -$I->wantTo('ensure login page works'); | |
| 9 | - | |
| 10 | -$loginPage = LoginPage::openBy($I); | |
| 11 | - | |
| 12 | -$I->amGoingTo('submit login form with no data'); | |
| 13 | -$loginPage->login('', ''); | |
| 14 | -$I->expectTo('see validations errors'); | |
| 15 | -$I->see('Username cannot be blank.', '.help-block'); | |
| 16 | -$I->see('Password cannot be blank.', '.help-block'); | |
| 17 | - | |
| 18 | -$I->amGoingTo('try to login with wrong credentials'); | |
| 19 | -$I->expectTo('see validations errors'); | |
| 20 | -$loginPage->login('admin', 'wrong'); | |
| 21 | -$I->expectTo('see validations errors'); | |
| 22 | -$I->see('Incorrect username or password.', '.help-block'); | |
| 23 | - | |
| 24 | -$I->amGoingTo('try to login with correct credentials'); | |
| 25 | -$loginPage->login('erau', 'password_0'); | |
| 26 | -$I->expectTo('see that user is logged'); | |
| 27 | -$I->seeLink('Logout (erau)'); | |
| 28 | -$I->dontSeeLink('Login'); | |
| 29 | -$I->dontSeeLink('Signup'); | |
| 30 | -/** Uncomment if using WebDriver | |
| 31 | - * $I->click('Logout (erau)'); | |
| 32 | - * $I->dontSeeLink('Logout (erau)'); | |
| 33 | - * $I->seeLink('Login'); | |
| 34 | - */ |
tests/codeception/frontend/acceptance/SignupCest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\acceptance; | |
| 4 | - | |
| 5 | -use tests\codeception\frontend\_pages\SignupPage; | |
| 6 | -use common\models\User; | |
| 7 | - | |
| 8 | -class SignupCest | |
| 9 | -{ | |
| 10 | - | |
| 11 | - /** | |
| 12 | - * This method is called before each cest class test method | |
| 13 | - * @param \Codeception\Event\TestEvent $event | |
| 14 | - */ | |
| 15 | - public function _before($event) | |
| 16 | - { | |
| 17 | - } | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * This method is called after each cest class test method, even if test failed. | |
| 21 | - * @param \Codeception\Event\TestEvent $event | |
| 22 | - */ | |
| 23 | - public function _after($event) | |
| 24 | - { | |
| 25 | - User::deleteAll([ | |
| 26 | - 'email' => 'tester.email@example.com', | |
| 27 | - 'username' => 'tester', | |
| 28 | - ]); | |
| 29 | - } | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * This method is called when test fails. | |
| 33 | - * @param \Codeception\Event\FailEvent $event | |
| 34 | - */ | |
| 35 | - public function _fail($event) | |
| 36 | - { | |
| 37 | - } | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * @param \codeception_frontend\AcceptanceTester $I | |
| 41 | - * @param \Codeception\Scenario $scenario | |
| 42 | - */ | |
| 43 | - public function testUserSignup($I, $scenario) | |
| 44 | - { | |
| 45 | - $I->wantTo('ensure that signup works'); | |
| 46 | - | |
| 47 | - $signupPage = SignupPage::openBy($I); | |
| 48 | - $I->see('Signup', 'h1'); | |
| 49 | - $I->see('Please fill out the following fields to signup:'); | |
| 50 | - | |
| 51 | - $I->amGoingTo('submit signup form with no data'); | |
| 52 | - | |
| 53 | - $signupPage->submit([]); | |
| 54 | - | |
| 55 | - $I->expectTo('see validation errors'); | |
| 56 | - $I->see('Username cannot be blank.', '.help-block'); | |
| 57 | - $I->see('Email cannot be blank.', '.help-block'); | |
| 58 | - $I->see('Password cannot be blank.', '.help-block'); | |
| 59 | - | |
| 60 | - $I->amGoingTo('submit signup form with not correct email'); | |
| 61 | - $signupPage->submit([ | |
| 62 | - 'username' => 'tester', | |
| 63 | - 'email' => 'tester.email', | |
| 64 | - 'password' => 'tester_password', | |
| 65 | - ]); | |
| 66 | - | |
| 67 | - $I->expectTo('see that email address is wrong'); | |
| 68 | - $I->dontSee('Username cannot be blank.', '.help-block'); | |
| 69 | - $I->dontSee('Password cannot be blank.', '.help-block'); | |
| 70 | - $I->see('Email is not a valid email address.', '.help-block'); | |
| 71 | - | |
| 72 | - $I->amGoingTo('submit signup form with correct email'); | |
| 73 | - $signupPage->submit([ | |
| 74 | - 'username' => 'tester', | |
| 75 | - 'email' => 'tester.email@example.com', | |
| 76 | - 'password' => 'tester_password', | |
| 77 | - ]); | |
| 78 | - | |
| 79 | - $I->expectTo('see that user logged in'); | |
| 80 | - $I->seeLink('Logout (tester)'); | |
| 81 | - } | |
| 82 | -} |
tests/codeception/frontend/acceptance/_bootstrap.php deleted
tests/codeception/frontend/codeception.yml deleted
| 1 | -namespace: tests\codeception\frontend | |
| 2 | -actor: Tester | |
| 3 | -paths: | |
| 4 | - tests: . | |
| 5 | - log: _output | |
| 6 | - data: _data | |
| 7 | - helpers: _support | |
| 8 | -settings: | |
| 9 | - bootstrap: _bootstrap.php | |
| 10 | - suite_class: \PHPUnit_Framework_TestSuite | |
| 11 | - colors: true | |
| 12 | - memory_limit: 1024M | |
| 13 | - log: true | |
| 14 | -config: | |
| 15 | - # the entry script URL (with host info) for functional and acceptance tests | |
| 16 | - # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL | |
| 17 | - test_entry_url: http://localhost:8080/frontend/web/index-test.php |
tests/codeception/frontend/functional.suite.yml deleted
| 1 | -# Codeception Test Suite Configuration | |
| 2 | - | |
| 3 | -# suite for functional (integration) tests. | |
| 4 | -# emulate web requests and make application process them. | |
| 5 | -# (tip: better to use with frameworks). | |
| 6 | - | |
| 7 | -# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | |
| 8 | -#basic/web/index.php | |
| 9 | -class_name: FunctionalTester | |
| 10 | -modules: | |
| 11 | - enabled: | |
| 12 | - - Filesystem | |
| 13 | - - Yii2 | |
| 14 | - - tests\codeception\common\_support\FixtureHelper | |
| 15 | - config: | |
| 16 | - Yii2: | |
| 17 | - configFile: '../config/frontend/functional.php' |
tests/codeception/frontend/functional/AboutCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\FunctionalTester; | |
| 3 | -use tests\codeception\frontend\_pages\AboutPage; | |
| 4 | - | |
| 5 | -/* @var $scenario Codeception\Scenario */ | |
| 6 | - | |
| 7 | -$I = new FunctionalTester($scenario); | |
| 8 | -$I->wantTo('ensure that about works'); | |
| 9 | -AboutPage::openBy($I); | |
| 10 | -$I->see('About', 'h1'); |
tests/codeception/frontend/functional/ContactCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\FunctionalTester; | |
| 3 | -use tests\codeception\frontend\_pages\ContactPage; | |
| 4 | - | |
| 5 | -/* @var $scenario Codeception\Scenario */ | |
| 6 | - | |
| 7 | -$I = new FunctionalTester($scenario); | |
| 8 | -$I->wantTo('ensure that contact works'); | |
| 9 | - | |
| 10 | -$contactPage = ContactPage::openBy($I); | |
| 11 | - | |
| 12 | -$I->see('Contact', 'h1'); | |
| 13 | - | |
| 14 | -$I->amGoingTo('submit contact form with no data'); | |
| 15 | -$contactPage->submit([]); | |
| 16 | -$I->expectTo('see validations errors'); | |
| 17 | -$I->see('Contact', 'h1'); | |
| 18 | -$I->see('Name cannot be blank', '.help-block'); | |
| 19 | -$I->see('Email cannot be blank', '.help-block'); | |
| 20 | -$I->see('Subject cannot be blank', '.help-block'); | |
| 21 | -$I->see('Body cannot be blank', '.help-block'); | |
| 22 | -$I->see('The verification code is incorrect', '.help-block'); | |
| 23 | - | |
| 24 | -$I->amGoingTo('submit contact form with not correct email'); | |
| 25 | -$contactPage->submit([ | |
| 26 | - 'name' => 'tester', | |
| 27 | - 'email' => 'tester.email', | |
| 28 | - 'subject' => 'test subject', | |
| 29 | - 'body' => 'test content', | |
| 30 | - 'verifyCode' => 'testme', | |
| 31 | -]); | |
| 32 | -$I->expectTo('see that email adress is wrong'); | |
| 33 | -$I->dontSee('Name cannot be blank', '.help-block'); | |
| 34 | -$I->see('Email is not a valid email address.', '.help-block'); | |
| 35 | -$I->dontSee('Subject cannot be blank', '.help-block'); | |
| 36 | -$I->dontSee('Body cannot be blank', '.help-block'); | |
| 37 | -$I->dontSee('The verification code is incorrect', '.help-block'); | |
| 38 | - | |
| 39 | -$I->amGoingTo('submit contact form with correct data'); | |
| 40 | -$contactPage->submit([ | |
| 41 | - 'name' => 'tester', | |
| 42 | - 'email' => 'tester@example.com', | |
| 43 | - 'subject' => 'test subject', | |
| 44 | - 'body' => 'test content', | |
| 45 | - 'verifyCode' => 'testme', | |
| 46 | -]); | |
| 47 | -$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); |
tests/codeception/frontend/functional/HomeCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\FunctionalTester; | |
| 3 | - | |
| 4 | -/* @var $scenario Codeception\Scenario */ | |
| 5 | - | |
| 6 | -$I = new FunctionalTester($scenario); | |
| 7 | -$I->wantTo('ensure that home page works'); | |
| 8 | -$I->amOnPage(Yii::$app->homeUrl); | |
| 9 | -$I->see('My Company'); | |
| 10 | -$I->seeLink('About'); | |
| 11 | -$I->click('About'); | |
| 12 | -$I->see('This is the About page.'); |
tests/codeception/frontend/functional/LoginCept.php deleted
| 1 | -<?php | |
| 2 | -use tests\codeception\frontend\FunctionalTester; | |
| 3 | -use tests\codeception\common\_pages\LoginPage; | |
| 4 | - | |
| 5 | -/* @var $scenario Codeception\Scenario */ | |
| 6 | - | |
| 7 | -$I = new FunctionalTester($scenario); | |
| 8 | -$I->wantTo('ensure login page works'); | |
| 9 | - | |
| 10 | -$loginPage = LoginPage::openBy($I); | |
| 11 | - | |
| 12 | -$I->amGoingTo('submit login form with no data'); | |
| 13 | -$loginPage->login('', ''); | |
| 14 | -$I->expectTo('see validations errors'); | |
| 15 | -$I->see('Username cannot be blank.', '.help-block'); | |
| 16 | -$I->see('Password cannot be blank.', '.help-block'); | |
| 17 | - | |
| 18 | -$I->amGoingTo('try to login with wrong credentials'); | |
| 19 | -$I->expectTo('see validations errors'); | |
| 20 | -$loginPage->login('admin', 'wrong'); | |
| 21 | -$I->expectTo('see validations errors'); | |
| 22 | -$I->see('Incorrect username or password.', '.help-block'); | |
| 23 | - | |
| 24 | -$I->amGoingTo('try to login with correct credentials'); | |
| 25 | -$loginPage->login('erau', 'password_0'); | |
| 26 | -$I->expectTo('see that user is logged'); | |
| 27 | -$I->seeLink('Logout (erau)'); | |
| 28 | -$I->dontSeeLink('Login'); | |
| 29 | -$I->dontSeeLink('Signup'); |
tests/codeception/frontend/functional/SignupCest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\functional; | |
| 4 | - | |
| 5 | -use tests\codeception\frontend\_pages\SignupPage; | |
| 6 | -use common\models\User; | |
| 7 | - | |
| 8 | -class SignupCest | |
| 9 | -{ | |
| 10 | - | |
| 11 | - /** | |
| 12 | - * This method is called before each cest class test method | |
| 13 | - * @param \Codeception\Event\TestEvent $event | |
| 14 | - */ | |
| 15 | - public function _before($event) | |
| 16 | - { | |
| 17 | - } | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * This method is called after each cest class test method, even if test failed. | |
| 21 | - * @param \Codeception\Event\TestEvent $event | |
| 22 | - */ | |
| 23 | - public function _after($event) | |
| 24 | - { | |
| 25 | - User::deleteAll([ | |
| 26 | - 'email' => 'tester.email@example.com', | |
| 27 | - 'username' => 'tester', | |
| 28 | - ]); | |
| 29 | - } | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * This method is called when test fails. | |
| 33 | - * @param \Codeception\Event\FailEvent $event | |
| 34 | - */ | |
| 35 | - public function _fail($event) | |
| 36 | - { | |
| 37 | - | |
| 38 | - } | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * | |
| 42 | - * @param \codeception_frontend\FunctionalTester $I | |
| 43 | - * @param \Codeception\Scenario $scenario | |
| 44 | - */ | |
| 45 | - public function testUserSignup($I, $scenario) | |
| 46 | - { | |
| 47 | - $I->wantTo('ensure that signup works'); | |
| 48 | - | |
| 49 | - $signupPage = SignupPage::openBy($I); | |
| 50 | - $I->see('Signup', 'h1'); | |
| 51 | - $I->see('Please fill out the following fields to signup:'); | |
| 52 | - | |
| 53 | - $I->amGoingTo('submit signup form with no data'); | |
| 54 | - | |
| 55 | - $signupPage->submit([]); | |
| 56 | - | |
| 57 | - $I->expectTo('see validation errors'); | |
| 58 | - $I->see('Username cannot be blank.', '.help-block'); | |
| 59 | - $I->see('Email cannot be blank.', '.help-block'); | |
| 60 | - $I->see('Password cannot be blank.', '.help-block'); | |
| 61 | - | |
| 62 | - $I->amGoingTo('submit signup form with not correct email'); | |
| 63 | - $signupPage->submit([ | |
| 64 | - 'username' => 'tester', | |
| 65 | - 'email' => 'tester.email', | |
| 66 | - 'password' => 'tester_password', | |
| 67 | - ]); | |
| 68 | - | |
| 69 | - $I->expectTo('see that email address is wrong'); | |
| 70 | - $I->dontSee('Username cannot be blank.', '.help-block'); | |
| 71 | - $I->dontSee('Password cannot be blank.', '.help-block'); | |
| 72 | - $I->see('Email is not a valid email address.', '.help-block'); | |
| 73 | - | |
| 74 | - $I->amGoingTo('submit signup form with correct email'); | |
| 75 | - $signupPage->submit([ | |
| 76 | - 'username' => 'tester', | |
| 77 | - 'email' => 'tester.email@example.com', | |
| 78 | - 'password' => 'tester_password', | |
| 79 | - ]); | |
| 80 | - | |
| 81 | - $I->expectTo('see that user is created'); | |
| 82 | - $I->seeRecord('common\models\User', [ | |
| 83 | - 'username' => 'tester', | |
| 84 | - 'email' => 'tester.email@example.com', | |
| 85 | - ]); | |
| 86 | - | |
| 87 | - $I->expectTo('see that user logged in'); | |
| 88 | - $I->seeLink('Logout (tester)'); | |
| 89 | - } | |
| 90 | -} |
tests/codeception/frontend/functional/_bootstrap.php deleted
tests/codeception/frontend/unit.suite.yml deleted
tests/codeception/frontend/unit/DbTestCase.php deleted
tests/codeception/frontend/unit/TestCase.php deleted
tests/codeception/frontend/unit/_bootstrap.php deleted
tests/codeception/frontend/unit/fixtures/data/models/user.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -return [ | |
| 4 | - [ | |
| 5 | - 'username' => 'okirlin', | |
| 6 | - 'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv', | |
| 7 | - 'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi', | |
| 8 | - 'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(), | |
| 9 | - 'created_at' => '1391885313', | |
| 10 | - 'updated_at' => '1391885313', | |
| 11 | - 'email' => 'brady.renner@rutherford.com', | |
| 12 | - ], | |
| 13 | - [ | |
| 14 | - 'username' => 'troy.becker', | |
| 15 | - 'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp', | |
| 16 | - 'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2', | |
| 17 | - 'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(), | |
| 18 | - 'created_at' => '1391885313', | |
| 19 | - 'updated_at' => '1391885313', | |
| 20 | - 'email' => 'nicolas.dianna@hotmail.com', | |
| 21 | - 'status' => '0', | |
| 22 | - ], | |
| 23 | -]; |
tests/codeception/frontend/unit/models/ContactFormTest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\unit\models; | |
| 4 | - | |
| 5 | -use Yii; | |
| 6 | -use tests\codeception\frontend\unit\TestCase; | |
| 7 | -use frontend\models\ContactForm; | |
| 8 | - | |
| 9 | -class ContactFormTest extends TestCase | |
| 10 | -{ | |
| 11 | - | |
| 12 | - use \Codeception\Specify; | |
| 13 | - | |
| 14 | - protected function setUp() | |
| 15 | - { | |
| 16 | - parent::setUp(); | |
| 17 | - Yii::$app->mailer->fileTransportCallback = function ($mailer, $message) { | |
| 18 | - return 'testing_message.eml'; | |
| 19 | - }; | |
| 20 | - } | |
| 21 | - | |
| 22 | - protected function tearDown() | |
| 23 | - { | |
| 24 | - unlink($this->getMessageFile()); | |
| 25 | - parent::tearDown(); | |
| 26 | - } | |
| 27 | - | |
| 28 | - public function testContact() | |
| 29 | - { | |
| 30 | - $model = new ContactForm(); | |
| 31 | - | |
| 32 | - $model->attributes = [ | |
| 33 | - 'name' => 'Tester', | |
| 34 | - 'email' => 'tester@example.com', | |
| 35 | - 'subject' => 'very important letter subject', | |
| 36 | - 'body' => 'body of current message', | |
| 37 | - ]; | |
| 38 | - | |
| 39 | - $model->sendEmail('admin@example.com'); | |
| 40 | - | |
| 41 | - $this->specify('email should be send', function () { | |
| 42 | - expect('email file should exist', file_exists($this->getMessageFile()))->true(); | |
| 43 | - }); | |
| 44 | - | |
| 45 | - $this->specify('message should contain correct data', function () use ($model) { | |
| 46 | - $emailMessage = file_get_contents($this->getMessageFile()); | |
| 47 | - | |
| 48 | - expect('email should contain user name', $emailMessage)->contains($model->name); | |
| 49 | - expect('email should contain sender email', $emailMessage)->contains($model->email); | |
| 50 | - expect('email should contain subject', $emailMessage)->contains($model->subject); | |
| 51 | - expect('email should contain body', $emailMessage)->contains($model->body); | |
| 52 | - }); | |
| 53 | - } | |
| 54 | - | |
| 55 | - private function getMessageFile() | |
| 56 | - { | |
| 57 | - return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; | |
| 58 | - } | |
| 59 | -} |
tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\models; | |
| 4 | - | |
| 5 | -use Yii; | |
| 6 | -use tests\codeception\frontend\unit\DbTestCase; | |
| 7 | -use frontend\models\PasswordResetRequestForm; | |
| 8 | -use tests\codeception\common\fixtures\UserFixture; | |
| 9 | -use common\models\User; | |
| 10 | -use Codeception\Specify; | |
| 11 | - | |
| 12 | -class PasswordResetRequestFormTest extends DbTestCase | |
| 13 | -{ | |
| 14 | - use Specify; | |
| 15 | - | |
| 16 | - protected function setUp() | |
| 17 | - { | |
| 18 | - parent::setUp(); | |
| 19 | - | |
| 20 | - Yii::$app->mailer->fileTransportCallback = function ($mailer, $message) { | |
| 21 | - return 'testing_message.eml'; | |
| 22 | - }; | |
| 23 | - } | |
| 24 | - | |
| 25 | - protected function tearDown() | |
| 26 | - { | |
| 27 | - @unlink($this->getMessageFile()); | |
| 28 | - | |
| 29 | - parent::tearDown(); | |
| 30 | - } | |
| 31 | - | |
| 32 | - public function testSendEmailWrongUser() | |
| 33 | - { | |
| 34 | - $this->specify('no user with such email, message should not be sent', function () { | |
| 35 | - | |
| 36 | - $model = new PasswordResetRequestForm(); | |
| 37 | - $model->email = 'not-existing-email@example.com'; | |
| 38 | - | |
| 39 | - expect('email not sent', $model->sendEmail())->false(); | |
| 40 | - | |
| 41 | - }); | |
| 42 | - | |
| 43 | - $this->specify('user is not active, message should not be sent', function () { | |
| 44 | - | |
| 45 | - $model = new PasswordResetRequestForm(); | |
| 46 | - $model->email = $this->user[1]['email']; | |
| 47 | - | |
| 48 | - expect('email not sent', $model->sendEmail())->false(); | |
| 49 | - | |
| 50 | - }); | |
| 51 | - } | |
| 52 | - | |
| 53 | - public function testSendEmailCorrectUser() | |
| 54 | - { | |
| 55 | - $model = new PasswordResetRequestForm(); | |
| 56 | - $model->email = $this->user[0]['email']; | |
| 57 | - $user = User::findOne(['password_reset_token' => $this->user[0]['password_reset_token']]); | |
| 58 | - | |
| 59 | - expect('email sent', $model->sendEmail())->true(); | |
| 60 | - expect('user has valid token', $user->password_reset_token)->notNull(); | |
| 61 | - | |
| 62 | - $this->specify('message has correct format', function () use ($model) { | |
| 63 | - | |
| 64 | - expect('message file exists', file_exists($this->getMessageFile()))->true(); | |
| 65 | - | |
| 66 | - $message = file_get_contents($this->getMessageFile()); | |
| 67 | - expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']); | |
| 68 | - expect('message "to" is correct', $message)->contains($model->email); | |
| 69 | - | |
| 70 | - }); | |
| 71 | - } | |
| 72 | - | |
| 73 | - public function fixtures() | |
| 74 | - { | |
| 75 | - return [ | |
| 76 | - 'user' => [ | |
| 77 | - 'class' => UserFixture::className(), | |
| 78 | - 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php' | |
| 79 | - ], | |
| 80 | - ]; | |
| 81 | - } | |
| 82 | - | |
| 83 | - private function getMessageFile() | |
| 84 | - { | |
| 85 | - return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; | |
| 86 | - } | |
| 87 | -} |
tests/codeception/frontend/unit/models/ResetPasswordFormTest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\unit\models; | |
| 4 | - | |
| 5 | -use tests\codeception\frontend\unit\DbTestCase; | |
| 6 | -use tests\codeception\common\fixtures\UserFixture; | |
| 7 | -use frontend\models\ResetPasswordForm; | |
| 8 | - | |
| 9 | -class ResetPasswordFormTest extends DbTestCase | |
| 10 | -{ | |
| 11 | - | |
| 12 | - /** | |
| 13 | - * @expectedException \yii\base\InvalidParamException | |
| 14 | - */ | |
| 15 | - public function testResetWrongToken() | |
| 16 | - { | |
| 17 | - new ResetPasswordForm('notexistingtoken_1391882543'); | |
| 18 | - } | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * @expectedException \yii\base\InvalidParamException | |
| 22 | - */ | |
| 23 | - public function testResetEmptyToken() | |
| 24 | - { | |
| 25 | - new ResetPasswordForm(''); | |
| 26 | - } | |
| 27 | - | |
| 28 | - public function testResetCorrectToken() | |
| 29 | - { | |
| 30 | - $form = new ResetPasswordForm($this->user[0]['password_reset_token']); | |
| 31 | - expect('password should be resetted', $form->resetPassword())->true(); | |
| 32 | - } | |
| 33 | - | |
| 34 | - public function fixtures() | |
| 35 | - { | |
| 36 | - return [ | |
| 37 | - 'user' => [ | |
| 38 | - 'class' => UserFixture::className(), | |
| 39 | - 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php' | |
| 40 | - ], | |
| 41 | - ]; | |
| 42 | - } | |
| 43 | -} |
tests/codeception/frontend/unit/models/SignupFormTest.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace tests\codeception\frontend\unit\models; | |
| 4 | - | |
| 5 | -use tests\codeception\frontend\unit\DbTestCase; | |
| 6 | -use tests\codeception\common\fixtures\UserFixture; | |
| 7 | -use Codeception\Specify; | |
| 8 | -use frontend\models\SignupForm; | |
| 9 | - | |
| 10 | -class SignupFormTest extends DbTestCase | |
| 11 | -{ | |
| 12 | - | |
| 13 | - use Specify; | |
| 14 | - | |
| 15 | - public function testCorrectSignup() | |
| 16 | - { | |
| 17 | - $model = new SignupForm([ | |
| 18 | - 'username' => 'some_username', | |
| 19 | - 'email' => 'some_email@example.com', | |
| 20 | - 'password' => 'some_password', | |
| 21 | - ]); | |
| 22 | - | |
| 23 | - $user = $model->signup(); | |
| 24 | - | |
| 25 | - $this->assertInstanceOf('common\models\User', $user, 'user should be valid'); | |
| 26 | - | |
| 27 | - expect('username should be correct', $user->username)->equals('some_username'); | |
| 28 | - expect('email should be correct', $user->email)->equals('some_email@example.com'); | |
| 29 | - expect('password should be correct', $user->validatePassword('some_password'))->true(); | |
| 30 | - } | |
| 31 | - | |
| 32 | - public function testNotCorrectSignup() | |
| 33 | - { | |
| 34 | - $model = new SignupForm([ | |
| 35 | - 'username' => 'troy.becker', | |
| 36 | - 'email' => 'nicolas.dianna@hotmail.com', | |
| 37 | - 'password' => 'some_password', | |
| 38 | - ]); | |
| 39 | - | |
| 40 | - expect('username and email are in use, user should not be created', $model->signup())->null(); | |
| 41 | - } | |
| 42 | - | |
| 43 | - public function fixtures() | |
| 44 | - { | |
| 45 | - return [ | |
| 46 | - 'user' => [ | |
| 47 | - 'class' => UserFixture::className(), | |
| 48 | - 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php', | |
| 49 | - ], | |
| 50 | - ]; | |
| 51 | - } | |
| 52 | -} |
tests/config/.gitignore deleted
tests/config/bootstrap.php deleted
| 1 | -<?php |
tests/config/main.php deleted
tests/config/params.php deleted
tests/config/unit.php deleted
tests/unit/EmailValidatorTest.php deleted
| 1 | -<?php | |
| 2 | -namespace tests\unit; | |
| 3 | - | |
| 4 | -use Codeception\TestCase\Test; | |
| 5 | -use yii\validators\EmailValidator; | |
| 6 | - | |
| 7 | -class EmailValidatorTest extends Test{ | |
| 8 | - | |
| 9 | - /** | |
| 10 | - * @dataProvider getEmailVariants | |
| 11 | - */ | |
| 12 | - public function testEmail($email, $result){ | |
| 13 | - $validator = new EmailValidator(); | |
| 14 | - $this->assertEquals($validator->validate($email), $result); | |
| 15 | - } | |
| 16 | - | |
| 17 | - public function getEmailVariants(){ | |
| 18 | - return [ | |
| 19 | - ['test@test.com', true], | |
| 20 | - ['test@test', false], | |
| 21 | - ['testtest.com', false] | |
| 22 | - ]; | |
| 23 | - } | |
| 24 | -} | |
| 25 | 0 | \ No newline at end of file |
tests/unit/UserStoreTest.php deleted
| 1 | -<?php | |
| 2 | -namespace tests\unit; | |
| 3 | -use common\components\UserStore; | |
| 4 | - | |
| 5 | -use Yii; | |
| 6 | - | |
| 7 | -class UserStoreTest extends \Codeception\TestCase\Test | |
| 8 | -{ | |
| 9 | - /** | |
| 10 | - * @var \UnitTester | |
| 11 | - */ | |
| 12 | - protected $tester; | |
| 13 | - | |
| 14 | - private $store; | |
| 15 | - | |
| 16 | - public function _before() | |
| 17 | - { | |
| 18 | - $this->store = new UserStore(); | |
| 19 | - } | |
| 20 | - | |
| 21 | - public function imagineCustomer(){ | |
| 22 | - $fake = \Faker\Factory::create(); | |
| 23 | - return [ | |
| 24 | - 'name' => $fake->name, | |
| 25 | - 'email' => $fake->email, | |
| 26 | - 'pass' => $fake->password(19), | |
| 27 | - ]; | |
| 28 | - | |
| 29 | - } | |
| 30 | - | |
| 31 | - public function testGetUser(){ | |
| 32 | - $imagineUser = $this->imagineCustomer(); | |
| 33 | - $this->store->addUser($imagineUser['name'],$imagineUser['email'],$imagineUser['pass']); | |
| 34 | - $user = $this->store->getUser($imagineUser['email']); | |
| 35 | - $this->assertEquals($user['name'], $imagineUser['name']); | |
| 36 | - $this->assertEquals($user['email'], $imagineUser['email']); | |
| 37 | - $this->assertEquals($user['pass'], $imagineUser['pass']); | |
| 38 | - } | |
| 39 | - | |
| 40 | - public function testAddUser_ShortPass(){ | |
| 41 | - $this->setExpectedException('\yii\base\Exception'); | |
| 42 | - $this->store->addUser('Some Name','collmail@gig.com','ff'); | |
| 43 | - } | |
| 44 | - | |
| 45 | - protected function _after() | |
| 46 | - { | |
| 47 | - } | |
| 48 | - | |
| 49 | - // tests | |
| 50 | -// public function testMe() | |
| 51 | -// { | |
| 52 | -// | |
| 53 | -// } | |
| 54 | -} | |
| 55 | 0 | \ No newline at end of file |
tests/unit/ValidatorTest.php deleted
| 1 | -<?php | |
| 2 | -namespace tests\unit; | |
| 3 | -use common\components\UserStore; | |
| 4 | - | |
| 5 | -use common\components\Validator; | |
| 6 | -use Yii; | |
| 7 | - | |
| 8 | -class ValidatorTest extends \Codeception\TestCase\Test | |
| 9 | -{ | |
| 10 | - public function testValidate_FalsePass(){ | |
| 11 | - $store = $this->getMock('common\components\UserStore'); | |
| 12 | - $this->validator = new Validator($store); | |
| 13 | - $store->expects($this->once()) | |
| 14 | - ->method('notifyPasswordFailure') | |
| 15 | - ->with($this->equalTo("test@emails.com")); | |
| 16 | - | |
| 17 | - $store->expects($this->any()) | |
| 18 | - ->method("getUser") | |
| 19 | - ->will($this->returnValue([ | |
| 20 | - "name"=>"fdsfdf", | |
| 21 | - "email"=>"test@emails.com", | |
| 22 | - "pass"=>"rihfhh" | |
| 23 | - ])); | |
| 24 | - | |
| 25 | - $this->assertFalse($this->validator->validateUser("test@emails.com", "wrong")); | |
| 26 | - } | |
| 27 | -} | |
| 28 | 0 | \ No newline at end of file |